From 53d8ca18fc57cf7f46a8d1f73ea112bafc6fc864 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Tue, 23 Jul 2024 12:19:43 -0400 Subject: [PATCH] Update to moonc v0.1.20240723+155a870f3 Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- README.md | 8 ++++---- examples/arrays/all-three.mbt | 2 +- examples/arrays/plugin-functions.mbt | 6 +++--- moon.mod.json | 4 ++-- pdk/http/method.mbt | 2 +- pdk/string.mbt | 8 ++++---- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 953b177..c8580b5 100644 --- a/README.md +++ b/README.md @@ -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()? @@ -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)]) @@ -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 ``` diff --git a/examples/arrays/all-three.mbt b/examples/arrays/all-three.mbt index b90c1e8..b11e217 100644 --- a/examples/arrays/all-three.mbt +++ b/examples/arrays/all-three.mbt @@ -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)] = [ diff --git a/examples/arrays/plugin-functions.mbt b/examples/arrays/plugin-functions.mbt index f4aa790..b80ad07 100644 --- a/examples/arrays/plugin-functions.mbt +++ b/examples/arrays/plugin-functions.mbt @@ -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( diff --git a/moon.mod.json b/moon.mod.json index 47fe98f..c8ccfc5 100644 --- a/moon.mod.json +++ b/moon.mod.json @@ -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", diff --git a/pdk/http/method.mbt b/pdk/http/method.mbt index 06016f8..7472daf 100644 --- a/pdk/http/method.mbt +++ b/pdk/http/method.mbt @@ -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()) diff --git a/pdk/string.mbt b/pdk/string.mbt index e482fd3..b3fb437 100644 --- a/pdk/string.mbt +++ b/pdk/string.mbt @@ -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()) @@ -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