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/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 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"]) 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 { 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)) } diff --git a/tests/dm/toml.dme b/tests/dm/toml.dme index f07eb45d..a570f4fa 100644 --- a/tests/dm/toml.dme +++ b/tests/dm/toml.dme @@ -15,9 +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") - // ~= checks for structural equality - if (toml_output != test_output) - CRASH("test:\n[test_toml]\n \nexpected:\n[test_output]\n \nrustg:\n[toml_output]") + if (toml_output != test_json) + CRASH("test:\n[test_toml]\n \nexpected:\n[test_json]\n \nrustg:\n[toml_output]")