Skip to content

Commit

Permalink
Update to moonc v0.1.20241115+351cfb074
Browse files Browse the repository at this point in the history
Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
  • Loading branch information
gmlewis committed Nov 16, 2024
1 parent 38e0844 commit 8928309
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,9 @@ The code has been updated to support compiler:

```bash
$ moon version --all
moon 0.1.20241111 (e6d64e0 2024-11-11) ~/.moon/bin/moon
moonc v0.1.20241111+dc2407357 ~/.moon/bin/moonc
moonrun 0.1.20241111 (e6d64e0 2024-11-11) ~/.moon/bin/moonrun
moon 0.1.20241115 (67c2b06 2024-11-15) ~/.moon/bin/moon
moonc v0.1.20241115+351cfb074 ~/.moon/bin/moonc
moonrun 0.1.20241115 (67c2b06 2024-11-15) ~/.moon/bin/moonrun
```

Use `moonup` to manage `moon` compiler versions:
Expand Down
2 changes: 1 addition & 1 deletion examples/arrays/all-three.mbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// `AllThree` represents a JSON object with all three array types.
pub struct AllThree {
pub(all) struct AllThree {
ints : Array[Int]
floats : Array[Double]
strings : Array[String]
Expand Down
2 changes: 1 addition & 1 deletion examples/count-vowels/count-vowels.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
let default_vowels = "aeiouAEIOU"

/// `VowelReport` represents the JSON struct returned to the host.
pub struct VowelReport {
pub(all) struct VowelReport {
count : Int
total : Int
vowels : String
Expand Down
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.42.0",
"version": "0.43.0",
"deps": {},
"readme": "README.md",
"repository": "https://github.com/extism/moonbit-pdk",
Expand Down
2 changes: 1 addition & 1 deletion pdk/config/config.mbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// `Config` provides methods to get "config" data from the host.
pub struct Config {}
pub(all) struct Config {}

/// `Config::get_memory` returns a "config" Memory block from the host that is keyed by `key`.
/// Note that no processing is performed on this block of memory.
Expand Down
2 changes: 1 addition & 1 deletion pdk/host/memory.mbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// `Memory` represents memory allocated by (and shared with) the host.
/// TODO: What kind of error checking needs to happen here?
pub struct Memory {
pub(all) struct Memory {
offset : Int64
length : Int64
}
Expand Down
2 changes: 1 addition & 1 deletion pdk/http/header.mbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// `Header` represents an HTTP Request header.
/// Multiple values for a single key are not deduped.
pub type Header Map[String, String] derive(Show, Eq, ToJson)
pub(all) type Header Map[String, String] derive(Show, Eq, ToJson)

/// `Header::new` returns a new Header.
pub fn Header::new() -> Header {
Expand Down
16 changes: 8 additions & 8 deletions pdk/http/http.mbt
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
/// `Request` represents an HTTP request made by the Extism host.
pub struct Request {
method : Method
pub(all) struct Request {
http_method : Method
header : Header
url : String
} derive(ToJson)

/// `Response` represents an HTTP response from the Extism host.
pub struct Response {
pub(all) struct Response {
status_code : Int
body : @host.Memory
}

/// `new_request` returns a new `Request` using the provided
/// `method` and `url`.
pub fn new_request(method : Method, url : String) -> Request {
pub fn new_request(http_method : Method, url : String) -> Request {
let header = Header::new()
{ method, header, url }
{ http_method, header, url }
}

/// `send` sends the `Request` to the host, waits for a response,
/// and returns it to the caller.
/// Note that the (optional) `body` is freed by this call.
pub fn send(self : Request, ~body : @host.Memory? = None) -> Response {
pub fn send(self : Request, body~ : @host.Memory? = None) -> Response {
let meta_mem = self.to_json() |> @host.allocate_json_value()
let body_memory_offset = match body {
Some(v) => v.offset
Expand Down Expand Up @@ -55,13 +55,13 @@ pub fn output(self : Response) -> Unit {

test "Request::to_json works as expected" {
let request = {
method: GET,
http_method: GET,
header: { "key1": "one", "key2": "two" },
url: "https://example.com",
}
let got = request.to_json().stringify(escape_slash=false)
let want =
#|{"method":"GET","header":{"key1":"one","key2":"two"},"url":"https://example.com"}
#|{"http_method":"GET","header":{"key1":"one","key2":"two"},"url":"https://example.com"}
assert_eq!(got, want)
}

Expand Down
2 changes: 1 addition & 1 deletion pdk/http/method.mbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// `Method` represents an HTTP method.
/// Descriptions are from: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods
pub enum Method {
pub(all) enum Method {
// The GET method requests a representation of the specified resource. Requests using GET should only retrieve data.
GET
// The HEAD method asks for a response identical to a GET request, but without the response body.
Expand Down
2 changes: 1 addition & 1 deletion pdk/string.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ pub impl ToUtf16 for Bytes with to_utf16(b : Bytes) -> String {
let char = Char::from_int(byte)
buf.write_char(char)
}
buf.to_string()
buf.to_unchecked_string()
}

0 comments on commit 8928309

Please sign in to comment.