Skip to content

Commit

Permalink
Support moonc v0.1.20240718+32d3b4fac
Browse files Browse the repository at this point in the history
Signed-off-by: Glenn Lewis <[email protected]>
  • Loading branch information
gmlewis committed Jul 18, 2024
1 parent cba3cf1 commit a509bae
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -541,12 +541,18 @@ To run the examples, type:

## Status

The code has been updated to support compiler `moon version`:
The code has been updated to support compiler:

```bash
moon 0.1.20240715 (0188781 2024-07-15)
$ moon version --all
moon 0.1.20240718 (e1aaec7 2024-07-18) ~/.moon/bin/moon
moonc v0.1.20240718+32d3b4fac ~/.moon/bin/moonc
moonrun 0.1.20240716 (08bce9c 2024-07-16) ~/.moon/bin/moonrun
```

Use [`moonup`] to manage `moon` compiler versions:
https://github.com/chawyehsu/moonup

## Reach Out!

Have a question or just want to drop in and say hi? [Hop on the Discord](https://extism.org/discord)!
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
# moon build --target wasm --output-wat

moon build --target wasm
moon test
2 changes: 1 addition & 1 deletion moon.mod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "extism/moonbit-pdk",
"version": "0.22.0",
"version": "0.23.0",
"deps": {
"gmlewis/json": "0.15.0"
},
Expand Down
2 changes: 1 addition & 1 deletion pdk/host/host.mbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// `input` returns a sequence of (unprocessed) bytes from the host.
pub fn input() -> Bytes {
let length = @extism.input_length().to_int()
let value = Bytes::make(length)
let value = Bytes::new(length)
for i = 0; i < length; i = i + 1 {
value[i] = @extism.input_load_u8(i.to_int64())
}
Expand Down
2 changes: 1 addition & 1 deletion pdk/host/memory.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub fn to_int(self : Memory) -> Int {
/// `to_bytes` reads the (unprocessed) bytes residing in the host memory
/// to a MoonBit Bytes.
pub fn to_bytes(self : Memory) -> Bytes {
let bytes = Bytes::make(self.length.to_int())
let bytes = Bytes::new(self.length.to_int())
for i = 0L; i < self.length; i = i + 1L {
let byte = @extism.load_u8(self.offset + i)
bytes[i.to_int()] = byte
Expand Down
4 changes: 2 additions & 2 deletions pdk/string.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ pub trait ToUtf8 {
pub fn ToUtf8::to_utf8(s : String) -> Bytes {
let chars = s.to_array()
// first, allocate the maximum possible length of the UTF-8 "string":
let bytes = Bytes::make(4 * chars.length())
let bytes = Bytes::new(4 * chars.length())
let mut length = 0
for i = 0; i < chars.length(); i = i + 1 {
length += bytes.set_utf8_char(length, chars[i])
}
// now that the size is known exactly (length), make a blit_copy:
let result = Bytes::make(length)
let result = Bytes::new(length)
result.blit(0, bytes, 0, length)
result
}
Expand Down
2 changes: 1 addition & 1 deletion pdk/var/var.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub fn set_bytes(key : String, value : Bytes) -> Unit {
/// `set_int` sets the host's "var" Int associated with the provided `key`.
pub fn set_int(key : String, value : Int) -> Unit {
let key_mem = @host.allocate_string(key)
let bytes = Bytes::make(4)
let bytes = Bytes::new(4)
bytes[0] = value.land(255).to_byte()
bytes[1] = value.lsr(8).land(255).to_byte()
bytes[2] = value.lsr(16).land(255).to_byte()
Expand Down

0 comments on commit a509bae

Please sign in to comment.