Skip to content

Commit

Permalink
Update to moonc v0.1.20240723+155a870f3
Browse files Browse the repository at this point in the history
Signed-off-by: Glenn Lewis <[email protected]>
  • Loading branch information
gmlewis committed Jul 23, 2024
1 parent c0da251 commit 53d8ca1
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ hopefully this situation will improve as the standard library is fleshed out.)
struct Add {
a : Int
b : Int
} derive(Debug)
}

pub fn Add::from_json(value : @json.JsonValue) -> Add? {
let value = value.as_object()?
Expand Down Expand Up @@ -201,7 +201,7 @@ pub fn Add::parse(s : String) -> Add!String {

struct Sum {
sum : Int
} derive(Debug)
}

pub impl @jsonutil.ToJson for Sum with to_json(self) {
@jsonutil.from_entries([("sum", self.sum)])
Expand Down Expand Up @@ -542,8 +542,8 @@ The code has been updated to support compiler:

```bash
$ moon version --all
moon 0.1.20240722 (1aa2132 2024-07-22) ~/.moon/bin/moon
moonc v0.1.20240722+695ec21e1 ~/.moon/bin/moonc
moon 0.1.20240723 (2c8c62f 2024-07-23) ~/.moon/bin/moon
moonc v0.1.20240723+155a870f3 ~/.moon/bin/moonc
moonrun 0.1.20240716 (08bce9c 2024-07-16) ~/.moon/bin/moonrun
```

Expand Down
2 changes: 1 addition & 1 deletion examples/arrays/all-three.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub struct AllThree {
ints : Array[Int]
floats : Array[Double]
strings : Array[String]
} derive(Debug, Eq, Show)
} derive(Eq, Show)

pub impl @jsonutil.ToJson for AllThree with to_json(self) {
let fields : Array[(String, @jsonutil.ToJson)] = [
Expand Down
6 changes: 3 additions & 3 deletions examples/arrays/plugin-functions.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ pub fn all_three_object() -> Int {
let all_three : AllThree = match jv {
Object(
{
"ints": Some(Array(ints)),
"floats": Some(Array(floats)),
"strings": Some(Array(strings)),
"ints": Array(ints),
"floats": Array(floats),
"strings": Array(strings),
}
) => {
let ints : Array[Int] = ints.map(fn { n => n.as_number() }).filter(
Expand Down
4 changes: 2 additions & 2 deletions moon.mod.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "extism/moonbit-pdk",
"version": "0.28.0",
"version": "0.29.0",
"deps": {
"gmlewis/jsonutil": "0.18.0"
"gmlewis/jsonutil": "0.19.0"
},
"readme": "README.md",
"repository": "https://github.com/extism/moonbit-pdk",
Expand Down
2 changes: 1 addition & 1 deletion pdk/http/method.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub enum Method {
TRACE
// The PATCH method applies partial modifications to a resource.
PATCH
} derive(Debug, Show)
} derive(Show)

impl @jsonutil.ToJson for Method with to_json(self) {
@json.JsonValue::String(self.to_string())
Expand Down
8 changes: 4 additions & 4 deletions pdk/string.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ pub trait ToUtf8 {
to_utf8(Self) -> Bytes
}

/// `ToUtf8::to_utf8` converts the MoonBit (UTF-16) `String` to a UTF-8 encoded `Bytes`.
pub fn ToUtf8::to_utf8(s : String) -> Bytes {
/// `to_utf8` converts the MoonBit (UTF-16) `String` to a UTF-8 encoded `Bytes`.
pub impl ToUtf8 for String with to_utf8(s : String) -> Bytes {
let chars = s.to_array()
// first, allocate the maximum possible length of the UTF-8 "string":
let bytes = Bytes::new(4 * chars.length())
Expand All @@ -27,8 +27,8 @@ pub trait ToUtf16 {
to_utf16(Self) -> String
}

/// `ToUtf16::to_utf16` converts a UTF-8 encoded `Bytes` to a MoonBit (UTF-16) `String`.
pub fn ToUtf16::to_utf16(b : Bytes) -> String {
/// `to_utf16` converts a UTF-8 encoded `Bytes` to a MoonBit (UTF-16) `String`.
pub impl ToUtf16 for Bytes with to_utf16(b : Bytes) -> String {
// TODO: Make a real UTF-8 => UTF-16 converter.
// For now, support ASCII.
// https://github.com/moonbitlang/core/issues/484
Expand Down

0 comments on commit 53d8ca1

Please sign in to comment.