From 6aeef82adab2a863f763d978d0daac59e33c49a4 Mon Sep 17 00:00:00 2001 From: tralezab Date: Wed, 1 Jun 2022 20:01:01 -0700 Subject: [PATCH 1/8] some interesting things were learned about rust... --- .vscode/settings.json | 2 +- src/toml.rs | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 36268ab1..111ee693 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,3 @@ { - "rust-analyzer.cargo.target": "i686-pc-windows-gnu" + "rust-analyzer.cargo.target": "i686-pc-windows-msvc" } diff --git a/src/toml.rs b/src/toml.rs index 140d8fbb..a28916af 100644 --- a/src/toml.rs +++ b/src/toml.rs @@ -1,7 +1,16 @@ use crate::error::Result; byond_fn!(fn toml_file_to_json(path) { - toml_file_to_json_impl(path).ok() + serde_json::to_string( + &match toml_file_to_json_impl(path) { + Ok(value) => serde_json::json!({ + "success": true, "content": value + }), + Err(error) => serde_json::json!({ + "success": false, "content": error.to_string() + }), + } + ).ok() }); fn toml_file_to_json_impl(path: &str) -> Result { From 1683aabe35ca06c732399c630a737fb77fb451d7 Mon Sep 17 00:00:00 2001 From: tralezab Date: Fri, 3 Jun 2022 10:55:17 -0700 Subject: [PATCH 2/8] dmsrc addition --- dmsrc/toml.dm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dmsrc/toml.dm b/dmsrc/toml.dm index e4033018..d30d2bb8 100644 --- a/dmsrc/toml.dm +++ b/dmsrc/toml.dm @@ -1 +1,8 @@ -#define rustg_read_toml_file(path) json_decode(call(RUST_G, "toml_file_to_json")(path) || "null") +#define rustg_raw_read_toml_file(path) json_decode(call(RUST_G, "toml_file_to_json")(path) || "null") + +/proc/rustg_read_toml_file(path) + var/list/output = rustg_raw_read_toml_file(path) + if (output["success"]) + return output["content"] + else + CRASH(output["content"]) From 8938159e07227dedbaa8ded30f8445e72ff30b2a Mon Sep 17 00:00:00 2001 From: tralezab Date: Mon, 27 Jun 2022 18:02:43 -0700 Subject: [PATCH 3/8] okay I admit it, I have no idea how to run tests --- tests/dm/toml.dme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/dm/toml.dme b/tests/dm/toml.dme index f07eb45d..e6bd07fd 100644 --- a/tests/dm/toml.dme +++ b/tests/dm/toml.dme @@ -19,5 +19,5 @@ var/test_json = @{" var/test_output = json_encode(json_decode(test_json)) // Double-encode so true becomes 1 // ~= checks for structural equality - if (toml_output != test_output) + if (toml_output["content"] != test_output) CRASH("test:\n[test_toml]\n \nexpected:\n[test_output]\n \nrustg:\n[toml_output]") From a4c2d1a1284121cedf05edde06d1f0d9c4eb2d93 Mon Sep 17 00:00:00 2001 From: ZeWaka Date: Wed, 20 Jul 2022 22:58:40 -0700 Subject: [PATCH 4/8] Clippy fix --- tests/abc-tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/abc-tests.rs b/tests/abc-tests.rs index 0923c669..763e8f5d 100644 --- a/tests/abc-tests.rs +++ b/tests/abc-tests.rs @@ -6,7 +6,7 @@ fn are_captures_sorted(matches: CaptureMatches, context: &str) -> Result<(), Str let mut prev_string = ""; for cap in matches { let capstring = cap.get(0).unwrap().as_str(); - match prev_string.cmp(&capstring) { + match prev_string.cmp(capstring) { Ordering::Greater => { return Err(format!("{} is not sorted in {}", &capstring, &context)) } From d5989bd34180bcf7a6d118a4a5c65cee483bafd1 Mon Sep 17 00:00:00 2001 From: ZeWaka Date: Wed, 20 Jul 2022 23:05:17 -0700 Subject: [PATCH 5/8] adds to readme about the pc-windows-gnu target --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 92cf6c81..13b8ceb2 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,11 @@ System libraries: * Other Linux distributions install the appropriate **32-bit development** and **32-bit runtime** packages. +If you want to use the `pc-windows-gnu` or similar other target ABI, do the following: +1. Change the `"rust-analyzer.cargo.target"` setting in `.cargo/config` to `i686-pc-windows-gnu`. +2. Run `git update-index --assume-unchanged .cargo/config`, which will tell git to 'ignore' the changes you made. +3. If you find yourself ever wanting to change back, run `git update-index --no-assume-unchanged .cargo/config`. + ## Compiling The [Cargo] tool handles compilation, as well as automatically downloading and From 21e2bd74e2544634c639bb9eb5f6719dd40aaa31 Mon Sep 17 00:00:00 2001 From: ZeWaka Date: Wed, 20 Jul 2022 23:52:15 -0700 Subject: [PATCH 6/8] fixes extra dm json unwrap already done in /proc/rustg_read_toml_file --- tests/dm/toml.dme | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/dm/toml.dme b/tests/dm/toml.dme index e6bd07fd..034df974 100644 --- a/tests/dm/toml.dme +++ b/tests/dm/toml.dme @@ -18,6 +18,5 @@ var/test_json = @{" var/toml_output = json_encode(rustg_read_toml_file("test.toml")) var/test_output = json_encode(json_decode(test_json)) // Double-encode so true becomes 1 - // ~= checks for structural equality - if (toml_output["content"] != test_output) + if (toml_output != test_output) CRASH("test:\n[test_toml]\n \nexpected:\n[test_output]\n \nrustg:\n[toml_output]") From 2bf85cc312b3de4e7e20f27ba2945c61535c6cdd Mon Sep 17 00:00:00 2001 From: ZeWaka Date: Thu, 21 Jul 2022 00:21:25 -0700 Subject: [PATCH 7/8] removes recode since byond supports `true` in json --- tests/dm/toml.dme | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/dm/toml.dme b/tests/dm/toml.dme index 034df974..04615ea6 100644 --- a/tests/dm/toml.dme +++ b/tests/dm/toml.dme @@ -15,8 +15,7 @@ var/test_json = @{" /test/proc/check_toml_file2json() rustg_file_write(test_toml, "test.toml") - var/toml_output = json_encode(rustg_read_toml_file("test.toml")) - var/test_output = json_encode(json_decode(test_json)) // Double-encode so true becomes 1 + var/toml_output = rustg_read_toml_file("test.toml") if (toml_output != test_output) - CRASH("test:\n[test_toml]\n \nexpected:\n[test_output]\n \nrustg:\n[toml_output]") + CRASH("test:\n[test_toml]\n \nexpected:\n[test_json]\n \nrustg:\n[toml_output]") From d85331cb24b17b9932fb1ab8e19c4af0d6db4b5f Mon Sep 17 00:00:00 2001 From: ZeWaka Date: Thu, 21 Jul 2022 00:27:31 -0700 Subject: [PATCH 8/8] 5min dm compilation error moment --- tests/dm/toml.dme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/dm/toml.dme b/tests/dm/toml.dme index 04615ea6..a570f4fa 100644 --- a/tests/dm/toml.dme +++ b/tests/dm/toml.dme @@ -17,5 +17,5 @@ var/test_json = @{" var/toml_output = rustg_read_toml_file("test.toml") - if (toml_output != test_output) + if (toml_output != test_json) CRASH("test:\n[test_toml]\n \nexpected:\n[test_json]\n \nrustg:\n[toml_output]")