From 198f1d9de397dd05cfc1d49e0baf0ce1348116e3 Mon Sep 17 00:00:00 2001 From: Katherine Kiefer Date: Sat, 9 Mar 2024 20:12:16 +1100 Subject: [PATCH] updates people --- Cargo.lock | 283 ++++++++++++------ Cargo.toml | 16 +- crates/auxcallback/Cargo.toml | 8 +- crates/byondapi-binds/Cargo.toml | 13 - .../byondapi-binds/byondapi-impl/Cargo.toml | 18 -- .../byondapi-binds/byondapi-impl/src/lib.rs | 217 -------------- crates/byondapi-binds/src/lib.rs | 72 ----- src/gas.rs | 1 + src/gas/types.rs | 9 +- src/init_shutdown.rs | 3 - src/lib.rs | 103 +++---- src/parser.rs | 2 +- src/turfs.rs | 8 +- src/turfs/groups.rs | 2 +- src/turfs/katmos.rs | 2 +- src/turfs/processing.rs | 6 +- 16 files changed, 280 insertions(+), 483 deletions(-) delete mode 100644 crates/byondapi-binds/Cargo.toml delete mode 100644 crates/byondapi-binds/byondapi-impl/Cargo.toml delete mode 100644 crates/byondapi-binds/byondapi-impl/src/lib.rs delete mode 100644 crates/byondapi-binds/src/lib.rs delete mode 100644 src/init_shutdown.rs diff --git a/Cargo.lock b/Cargo.lock index 4bdfa8d6..7c912960 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,11 +2,26 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "ahash" -version = "0.8.8" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42cd52102d3df161c77a887b608d7a4897d7cc112886a9537b738a887a03aaff" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", "getrandom", @@ -61,7 +76,6 @@ dependencies = [ "auxcallback", "bitflags 2.4.2", "byondapi", - "byondapi-binds", "coarsetime", "dashmap", "eyre", @@ -77,9 +91,25 @@ dependencies = [ "parking_lot", "petgraph", "rayon", + "stable-eyre", "tinyvec", ] +[[package]] +name = "backtrace" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "bindgen" version = "0.69.4" @@ -117,36 +147,31 @@ checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" [[package]] name = "byondapi" -version = "0.3.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f40d3a2391202c43ee2e3ab29cbc83164e060d94b2786ae442c7e5868ffb4d6" +checksum = "869198df801771233877f700bd5053bc2f06223bafeaabe9f5b375051ec5ccc4" dependencies = [ + "byondapi-macros", "byondapi-sys", "inventory", "lazy_static", "libloading", + "num_enum", "walkdir", ] [[package]] -name = "byondapi-binds" -version = "0.1.0" -dependencies = [ - "byondapi-impl", - "inventory", -] - -[[package]] -name = "byondapi-impl" -version = "0.1.0" +name = "byondapi-macros" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efa6006a3e4ebc48ae6780b1b4513451c56d7cfea24bc5907db9275616792d9a" dependencies = [ - "inventory", "proc-macro2", "quote", "syn", @@ -173,9 +198,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" -version = "1.0.85" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b918671670962b48bc23753aef0c51d072dca6f52f01f800854ada6ddb7f7d3" +checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" [[package]] name = "cexpr" @@ -281,7 +306,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] @@ -352,6 +377,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + [[package]] name = "glob" version = "0.3.1" @@ -374,7 +405,7 @@ version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" dependencies = [ - "windows-sys 0.52.0", + "windows-sys", ] [[package]] @@ -385,9 +416,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "2.2.3" +version = "2.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177" +checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" dependencies = [ "equivalent", "hashbrown", @@ -411,9 +442,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.68" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] @@ -438,12 +469,12 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libloading" -version = "0.8.1" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" +checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "windows-sys 0.48.0", + "windows-targets 0.52.4", ] [[package]] @@ -474,9 +505,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" @@ -499,6 +530,15 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" +[[package]] +name = "miniz_oxide" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +dependencies = [ + "adler", +] + [[package]] name = "nanorand" version = "0.7.0" @@ -518,6 +558,36 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "num_enum" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "object" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.19.0" @@ -609,6 +679,15 @@ dependencies = [ "syn", ] +[[package]] +name = "proc-macro-crate" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +dependencies = [ + "toml_edit", +] + [[package]] name = "proc-macro2" version = "1.0.78" @@ -644,9 +723,9 @@ checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" [[package]] name = "rayon" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051" +checksum = "e4963ed1bc86e4f3ee217022bd855b297cef07fb9eac5dfa1f788b220b49b3bd" dependencies = [ "either", "rayon-core", @@ -685,9 +764,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", @@ -700,6 +779,12 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + [[package]] name = "rustc-hash" version = "1.1.0" @@ -725,7 +810,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] @@ -745,9 +830,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "semver" -version = "1.0.21" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" +checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "shlex" @@ -776,11 +861,22 @@ dependencies = [ "lock_api", ] +[[package]] +name = "stable-eyre" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "556fec8c2da34c70b75f16d88df8a8cd7e652e567ff097b7e9df0022c8695cc4" +dependencies = [ + "backtrace", + "eyre", + "indenter", +] + [[package]] name = "syn" -version = "2.0.48" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -802,6 +898,23 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +[[package]] +name = "toml_datetime" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" + +[[package]] +name = "toml_edit" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + [[package]] name = "unicode-ident" version = "1.0.12" @@ -816,9 +929,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "walkdir" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", "winapi-util", @@ -841,9 +954,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -851,9 +964,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", @@ -866,9 +979,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -876,9 +989,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", @@ -889,9 +1002,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "which" @@ -936,22 +1049,13 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.4", ] [[package]] @@ -971,17 +1075,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.4", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm 0.52.4", + "windows_x86_64_msvc 0.52.4", ] [[package]] @@ -992,9 +1096,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" [[package]] name = "windows_aarch64_msvc" @@ -1004,9 +1108,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" [[package]] name = "windows_i686_gnu" @@ -1016,9 +1120,9 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" [[package]] name = "windows_i686_msvc" @@ -1028,9 +1132,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" [[package]] name = "windows_x86_64_gnu" @@ -1040,9 +1144,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" [[package]] name = "windows_x86_64_gnullvm" @@ -1052,9 +1156,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" [[package]] name = "windows_x86_64_msvc" @@ -1064,9 +1168,18 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" + +[[package]] +name = "winnow" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] [[package]] name = "zerocopy" diff --git a/Cargo.toml b/Cargo.toml index d9c80e54..ff70dff8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,8 +2,10 @@ members = ["crates/*"] [workspace.dependencies] -byondapi = "0.3.1" -byondapi-binds = { path = "./crates/byondapi-binds" } +byondapi = "0.4.2" +coarsetime = "0.1.34" +flume = "0.11.0" +eyre = "0.6.12" [package] name = "auxmos" @@ -37,13 +39,14 @@ all_reaction_hooks = [ crate-type = ["cdylib"] [dependencies] +byondapi = { workspace = true } +flume = { workspace = true } +coarsetime = { workspace = true } +eyre = { workspace = true } auxcallback = { path = "./crates/auxcallback" } -byondapi-binds = { path = "./crates/byondapi-binds" } -byondapi = "0.3.1" itertools = "0.12.1" rayon = "1.8.1" float-ord = "0.3.2" -flume = "0.11.0" parking_lot = "0.12.1" fxhash = "0.2.1" ahash = "0.8.8" @@ -55,9 +58,8 @@ atomic_float = "0.1.0" petgraph = "0.6.4" bitflags = "2.4.2" nom = "7.1.3" -coarsetime = "0.1.34" mimalloc = { version = "0.1.39", default-features = false } -eyre = "0.6.12" +stable-eyre = "0.2.2" [dependencies.tinyvec] version = "1.6.0" diff --git a/crates/auxcallback/Cargo.toml b/crates/auxcallback/Cargo.toml index 2f6c12ec..b5a0ed80 100644 --- a/crates/auxcallback/Cargo.toml +++ b/crates/auxcallback/Cargo.toml @@ -10,7 +10,7 @@ edition = "2018" crate-type = ["lib"] [dependencies] -flume = "0.11.0" -coarsetime = "0.1.34" -byondapi = "0.3.1" -eyre = "0.6.12" +byondapi = { workspace = true } +flume = { workspace = true } +coarsetime = { workspace = true } +eyre = { workspace = true } diff --git a/crates/byondapi-binds/Cargo.toml b/crates/byondapi-binds/Cargo.toml deleted file mode 100644 index 3d0eced4..00000000 --- a/crates/byondapi-binds/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "byondapi-binds" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[lib] -crate-type = ["lib"] - -[dependencies] -inventory = "0.3.15" -byondapi-impl = { path = "./byondapi-impl", package = "byondapi-impl" } diff --git a/crates/byondapi-binds/byondapi-impl/Cargo.toml b/crates/byondapi-binds/byondapi-impl/Cargo.toml deleted file mode 100644 index bbd85fa0..00000000 --- a/crates/byondapi-binds/byondapi-impl/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "byondapi-impl" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[lib] -proc-macro = true - -[dependencies] -inventory = "0.3.15" -quote = "1.0" -proc-macro2 = "1.0" - -[dependencies.syn] -version = "2.0" -features = ["full", "parsing", "printing"] diff --git a/crates/byondapi-binds/byondapi-impl/src/lib.rs b/crates/byondapi-binds/byondapi-impl/src/lib.rs deleted file mode 100644 index 5caadcd2..00000000 --- a/crates/byondapi-binds/byondapi-impl/src/lib.rs +++ /dev/null @@ -1,217 +0,0 @@ -use proc_macro::TokenStream; -use proc_macro2::Ident; -use quote::quote; -use syn::{spanned::Spanned, Lit}; - -fn extract_args(a: &syn::FnArg) -> &syn::PatType { - match a { - syn::FnArg::Typed(p) => p, - _ => panic!("Not supported on types with `self`!"), - } -} - -#[proc_macro_attribute] -pub fn bind(attr: TokenStream, item: TokenStream) -> TokenStream { - let input = syn::parse_macro_input!(item as syn::ItemFn); - let proc = syn::parse_macro_input!(attr as Option); - - let func_name = &input.sig.ident; - let func_name_disp = quote!(#func_name).to_string(); - - let func_name_ffi = format!("{func_name_disp}_ffi"); - let func_name_ffi = Ident::new(&func_name_ffi, func_name.span()); - let func_name_ffi_disp = quote!(#func_name_ffi).to_string(); - - let args = &input.sig.inputs; - - //Check for returns - match &input.sig.output { - syn::ReturnType::Default => {} // - - syn::ReturnType::Type(_, ty) => { - return syn::Error::new(ty.span(), "Do not specify the return value of binds") - .to_compile_error() - .into() - } - } - - let signature = quote! { - #[no_mangle] - pub unsafe extern "C" fn #func_name_ffi ( - __argc: ::byondapi::sys::u4c, - __argv: *mut ::byondapi::value::ByondValue - ) -> ::byondapi::value::ByondValue - }; - - let body = &input.block; - let mut arg_names: syn::punctuated::Punctuated = - syn::punctuated::Punctuated::new(); - let mut proc_arg_unpacker: syn::punctuated::Punctuated< - proc_macro2::TokenStream, - syn::Token![,], - > = syn::punctuated::Punctuated::new(); - - for arg in args.iter().map(extract_args) { - if let syn::Pat::Ident(p) = &*arg.pat { - arg_names.push(p.ident.clone()); - let index = arg_names.len() - 1; - proc_arg_unpacker.push(quote! { - args.get(#index).map(::byondapi::value::ByondValue::clone).unwrap_or_default() - }); - } - } - - let arg_names_disp = quote!(#arg_names).to_string(); - - //Submit to inventory - let cthook_prelude = match &proc { - Some(Lit::Str(p)) => { - quote! { - ::byondapi_binds::inventory::submit!({ - ::byondapi_binds::Bind { - proc_path: #p, - func_name: #func_name_ffi_disp, - func_arguments: #arg_names_disp, - is_variadic: false, - } - }); - } - } - Some(other_literal) => { - return syn::Error::new( - other_literal.span(), - "Bind attributes must be a string literal or empty", - ) - .to_compile_error() - .into() - } - None => quote! { - ::byondapi_binds::inventory::submit!({ - ::byondapi_binds::Bind{ - proc_path: #func_name_disp, - func_name: #func_name_ffi_disp, - func_arguments: #arg_names_disp, - is_variadic: false, - } - }); - }, - }; - - let result = quote! { - #cthook_prelude - #signature { - let args = unsafe { ::byondapi::parse_args(__argc, __argv) }; - match #func_name(#proc_arg_unpacker) { - Ok(val) => val, - Err(e) => { - let error_string = ::byondapi::value::ByondValue::try_from(::std::format!("{e:?}")).unwrap(); - ::byondapi::global_call::call_global_id(byond_string!("stack_trace"), &[error_string]).unwrap(); - ::byondapi::value::ByondValue::null() - } - } - - } - fn #func_name(#args) -> ::eyre::Result<::byondapi::value::ByondValue> - #body - }; - result.into() -} - -#[proc_macro_attribute] -pub fn bind_raw_args(attr: TokenStream, item: TokenStream) -> TokenStream { - let input = syn::parse_macro_input!(item as syn::ItemFn); - let proc = syn::parse_macro_input!(attr as Option); - - let func_name = &input.sig.ident; - let func_name_disp = quote!(#func_name).to_string(); - - let func_name_ffi = format!("{func_name_disp}_ffi"); - let func_name_ffi = Ident::new(&func_name_ffi, func_name.span()); - let func_name_ffi_disp = quote!(#func_name_ffi).to_string(); - - //Check for returns - match &input.sig.output { - syn::ReturnType::Default => {} // - - syn::ReturnType::Type(_, ty) => { - return syn::Error::new(ty.span(), "Do not specify the return value of binds") - .to_compile_error() - .into() - } - } - - if !input.sig.inputs.is_empty() { - return syn::Error::new( - input.sig.inputs.span(), - "Do not specify arguments for raw arg binds", - ) - .to_compile_error() - .into(); - } - - let signature = quote! { - #[no_mangle] - pub unsafe extern "C" fn #func_name_ffi ( - __argc: ::byondapi::sys::u4c, - __argv: *mut ::byondapi::value::ByondValue - ) -> ::byondapi::value::ByondValue - }; - - let body = &input.block; - - //Submit to inventory - let cthook_prelude = match proc { - Some(Lit::Str(p)) => { - quote! { - ::byondapi_binds::inventory::submit!({ - ::byondapi_binds::Bind { - proc_path: #p, - func_name: #func_name_ffi_disp, - func_arguments: "", - is_variadic: true, - } - }); - } - } - Some(other_literal) => { - return syn::Error::new( - other_literal.span(), - "Bind attributes must be a string literal or empty", - ) - .to_compile_error() - .into() - } - None => quote! { - quote! { - ::byondapi_binds::inventory::submit!({ - ::byondapi_binds::Bind{ - proc_path: #func_name_disp, - func_name: #func_name_ffi_disp, - func_arguments: "", - is_variadic: true, - } - }); - - } - }, - }; - - let result = quote! { - #cthook_prelude - #signature { - let mut args = unsafe { ::byondapi::parse_args(__argc, __argv) }; - match #func_name(args) { - Ok(val) => val, - Err(e) => { - let error_string = ::byondapi::value::ByondValue::try_from(::std::format!("{e:?}")).unwrap(); - ::byondapi::global_call::call_global_id(byond_string!("stack_trace"), &[error_string]).unwrap(); - ::byondapi::value::ByondValue::null() - } - } - - } - fn #func_name(args: &mut [::byondapi::value::ByondValue]) -> ::eyre::Result<::byondapi::value::ByondValue> - #body - }; - result.into() -} diff --git a/crates/byondapi-binds/src/lib.rs b/crates/byondapi-binds/src/lib.rs deleted file mode 100644 index 48aa2b8e..00000000 --- a/crates/byondapi-binds/src/lib.rs +++ /dev/null @@ -1,72 +0,0 @@ -use std::io::Write; - -pub use byondapi_impl::{bind, bind_raw_args}; - -pub use inventory; - -pub struct Bind { - pub proc_path: &'static str, - pub func_name: &'static str, - pub func_arguments: &'static str, - pub is_variadic: bool, -} - -inventory::collect!(Bind); - -pub fn generate_bindings() { - _ = std::fs::remove_file("./bindings.dm"); - let mut file = std::fs::File::create("./bindings.dm").unwrap(); - file.write_all( - r#"//THIS FILE IS AUTOMATICALLY GENERATED BY AUXMOS, PLEASE DO NOT TOUCH IT -//PROC DEFINITIONS MAY MOVE AROUND, THIS IS NORMAL - -/* This comment bypasses grep checks */ /var/__auxmos - -/proc/__detect_auxmos() - if (world.system_type == UNIX) - return __auxmos = "libauxmos" - else - return __auxmos = "auxmos" - -#define AUXMOS (__auxmos || __detect_auxmos()) - -"# - .as_bytes(), - ) - .unwrap(); - for thing in inventory::iter:: { - let path = thing.proc_path; - let func_name = thing.func_name; - let func_arguments = thing.func_arguments; - let func_arguments_srcless = func_arguments - .to_owned() - .replace("src, ", "") - .replace("src", ""); - if thing.is_variadic { - //can't directly modify args, fuck you byond - file.write_all( - format!( - r#"{path}(...) - var/list/args_copy = args.Copy() - args_copy.Insert(1, src) - return call_ext(AUXMOS, "byond:{func_name}")(arglist(args_copy)) - -"# - ) - .as_bytes(), - ) - .unwrap() - } else { - file.write_all( - format!( - r#"{path}({func_arguments_srcless}) - return call_ext(AUXMOS, "byond:{func_name}")({func_arguments}) - -"# - ) - .as_bytes(), - ) - .unwrap() - } - } -} diff --git a/src/gas.rs b/src/gas.rs index ceb06e3e..52006064 100644 --- a/src/gas.rs +++ b/src/gas.rs @@ -31,6 +31,7 @@ static GAS_MIXTURES: RwLock>>> = const_rwlock(None); static NEXT_GAS_IDS: RwLock>> = const_rwlock(None); +#[byondapi::init] pub fn initialize_gases() { *GAS_MIXTURES.write() = Some(Vec::with_capacity(240_000)); *NEXT_GAS_IDS.write() = Some(Vec::with_capacity(2000)); diff --git a/src/gas/types.rs b/src/gas/types.rs index 6bba8457..14cdfb94 100644 --- a/src/gas/types.rs +++ b/src/gas/types.rs @@ -223,6 +223,7 @@ static GAS_INFO_BY_IDX: RwLock>> = const_rwlock(None); static GAS_SPECIFIC_HEATS: RwLock>> = const_rwlock(None); +#[byondapi::init] pub fn initialize_gas_info_structs() { *GAS_INFO_BY_STRING.write() = Some(DashMap::with_hasher(FxBuildHasher::default())); *GAS_INFO_BY_IDX.write() = Some(Vec::new()); @@ -243,7 +244,7 @@ pub fn destroy_gas_info_structs() { }); } -#[byondapi_binds::bind("/proc/_auxtools_register_gas")] +#[byondapi::bind("/proc/_auxtools_register_gas")] fn hook_register_gas(gas: ByondValue) { let gas_id = gas.read_string_id(byond_string!("id"))?; match GAS_INFO_BY_STRING @@ -281,7 +282,7 @@ fn hook_register_gas(gas: ByondValue) { Ok(ByondValue::null()) } -#[byondapi_binds::bind("/proc/auxtools_atmos_init")] +#[byondapi::bind("/proc/auxtools_atmos_init")] fn hook_init(gas_data: ByondValue) { let data = gas_data.read_var_id(byond_string!("datums"))?; data.iter()? @@ -325,7 +326,7 @@ fn get_reaction_info() -> BTreeMap { reaction_cache } -#[byondapi_binds::bind("/datum/controller/subsystem/air/proc/auxtools_update_reactions")] +#[byondapi::bind("/datum/controller/subsystem/air/proc/auxtools_update_reactions")] fn update_reactions() { *REACTION_INFO.write() = Some(get_reaction_info()); Ok(true.into()) @@ -428,7 +429,7 @@ pub fn update_gas_refs() { }); } -#[byondapi_binds::bind("/proc/finalize_gas_refs")] +#[byondapi::bind("/proc/finalize_gas_refs")] fn finalize_gas_refs() { update_gas_refs(); Ok(ByondValue::null()) diff --git a/src/init_shutdown.rs b/src/init_shutdown.rs deleted file mode 100644 index a80fb0f8..00000000 --- a/src/init_shutdown.rs +++ /dev/null @@ -1,3 +0,0 @@ -byondapi::inventory::submit! {byondapi::InitFunc(super::gas::initialize_gases)} -byondapi::inventory::submit! {byondapi::InitFunc(super::types::initialize_gas_info_structs)} -byondapi::inventory::submit! {byondapi::InitFunc(super::turfs::initialize_turfs)} diff --git a/src/lib.rs b/src/lib.rs index 28584970..a3f5c50b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,8 +5,6 @@ pub mod turfs; mod reaction; -pub mod init_shutdown; - mod parser; use byondapi::{map::byond_length, prelude::*}; @@ -24,34 +22,39 @@ use gas::constants::{ReactionReturn, GAS_MIN_MOLES, MINIMUM_MOLES_DELTA_TO_MOVE} #[global_allocator] static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; +#[byondapi::init] +pub fn init_eyre() { + stable_eyre::install().unwrap(); +} + /// Args: (ms). Runs callbacks until time limit is reached. If time limit is omitted, runs all callbacks. -#[byondapi_binds::bind("/proc/process_atmos_callbacks")] +#[byondapi::bind("/proc/process_atmos_callbacks")] fn atmos_callback_handle(remaining: ByondValue) { auxcallback::callback_processing_hook(remaining) } /// Fills in the first unused slot in the gas mixtures vector, or adds another one, then sets the argument ByondValue to point to it. -#[byondapi_binds::bind("/datum/gas_mixture/proc/__gasmixture_register")] +#[byondapi::bind("/datum/gas_mixture/proc/__gasmixture_register")] fn register_gasmixture_hook(src: ByondValue) { gas::GasArena::register_mix(src) } /// Adds the gas mixture's ID to the queue of mixtures that have been deleted, to be reused later. /// This version is only if auxcleanup is not being used; it should be called from /datum/gas_mixture/Del. -#[byondapi_binds::bind("/datum/gas_mixture/proc/__gasmixture_unregister")] +#[byondapi::bind("/datum/gas_mixture/proc/__gasmixture_unregister")] fn unregister_gasmixture_hook(src: ByondValue) { gas::GasArena::unregister_mix(&src); Ok(ByondValue::null()) } /// Returns: Heat capacity, in J/K (probably). -#[byondapi_binds::bind("/datum/gas_mixture/proc/heat_capacity")] +#[byondapi::bind("/datum/gas_mixture/proc/heat_capacity")] fn heat_cap_hook(src: ByondValue) { with_mix(&src, |mix| Ok(mix.heat_capacity().into())) } /// Args: (min_heat_cap). Sets the mix's minimum heat capacity. -#[byondapi_binds::bind("/datum/gas_mixture/proc/set_min_heat_capacity")] +#[byondapi::bind("/datum/gas_mixture/proc/set_min_heat_capacity")] fn min_heat_cap_hook(src: ByondValue, arg_min: ByondValue) { let min = arg_min.get_number()?; with_mix_mut(&src, |mix| { @@ -61,37 +64,37 @@ fn min_heat_cap_hook(src: ByondValue, arg_min: ByondValue) { } /// Returns: Amount of substance, in moles. -#[byondapi_binds::bind("/datum/gas_mixture/proc/total_moles")] +#[byondapi::bind("/datum/gas_mixture/proc/total_moles")] fn total_moles_hook(src: ByondValue) { - with_mix(&src, |mix| Ok(mix.total_moles().into())) + Ok(with_mix(&src, |mix| Ok(mix.total_moles().into()))?) } /// Returns: the mix's pressure, in kilopascals. -#[byondapi_binds::bind("/datum/gas_mixture/proc/return_pressure")] +#[byondapi::bind("/datum/gas_mixture/proc/return_pressure")] fn return_pressure_hook(src: ByondValue) { with_mix(&src, |mix| Ok(mix.return_pressure().into())) } /// Returns: the mix's temperature, in kelvins. -#[byondapi_binds::bind("/datum/gas_mixture/proc/return_temperature")] +#[byondapi::bind("/datum/gas_mixture/proc/return_temperature")] fn return_temperature_hook(src: ByondValue) { with_mix(&src, |mix| Ok(mix.get_temperature().into())) } /// Returns: the mix's volume, in liters. -#[byondapi_binds::bind("/datum/gas_mixture/proc/return_volume")] +#[byondapi::bind("/datum/gas_mixture/proc/return_volume")] fn return_volume_hook(src: ByondValue) { with_mix(&src, |mix| Ok(mix.volume.into())) } /// Returns: the mix's thermal energy, the product of the mixture's heat capacity and its temperature. -#[byondapi_binds::bind("/datum/gas_mixture/proc/thermal_energy")] +#[byondapi::bind("/datum/gas_mixture/proc/thermal_energy")] fn thermal_energy_hook(src: ByondValue) { with_mix(&src, |mix| Ok(mix.thermal_energy().into())) } /// Args: (mixture). Merges the gas from the giver into src, without modifying the giver mix. -#[byondapi_binds::bind("/datum/gas_mixture/proc/merge")] +#[byondapi::bind("/datum/gas_mixture/proc/merge")] fn merge_hook(src: ByondValue, giver: ByondValue) { with_mixes_custom(&src, &giver, |src_mix, giver_mix| { src_mix.write().merge(&giver_mix.read()); @@ -100,7 +103,7 @@ fn merge_hook(src: ByondValue, giver: ByondValue) { } /// Args: (mixture, ratio). Takes the given ratio of gas from src and puts it into the argument mixture. Ratio is a number between 0 and 1. -#[byondapi_binds::bind("/datum/gas_mixture/proc/__remove_ratio")] +#[byondapi::bind("/datum/gas_mixture/proc/__remove_ratio")] fn remove_ratio_hook(src: ByondValue, into: ByondValue, ratio_arg: ByondValue) { let ratio = ratio_arg.get_number().unwrap_or_default(); with_mixes_mut(&src, &into, |src_mix, into_mix| { @@ -110,7 +113,7 @@ fn remove_ratio_hook(src: ByondValue, into: ByondValue, ratio_arg: ByondValue) { } /// Args: (mixture, amount). Takes the given amount of gas from src and puts it into the argument mixture. Amount is amount of substance in moles. -#[byondapi_binds::bind("/datum/gas_mixture/proc/__remove")] +#[byondapi::bind("/datum/gas_mixture/proc/__remove")] fn remove_hook(src: ByondValue, into: ByondValue, amount_arg: ByondValue) { let amount = amount_arg.get_number().unwrap_or_default(); with_mixes_mut(&src, &into, |src_mix, into_mix| { @@ -120,7 +123,7 @@ fn remove_hook(src: ByondValue, into: ByondValue, amount_arg: ByondValue) { } /// Arg: (mixture). Makes src into a copy of the argument mixture. -#[byondapi_binds::bind("/datum/gas_mixture/proc/copy_from")] +#[byondapi::bind("/datum/gas_mixture/proc/copy_from")] fn copy_from_hook(src: ByondValue, giver: ByondValue) { with_mixes_custom(&src, &giver, |src_mix, giver_mix| { src_mix.write().copy_from_mutable(&giver_mix.read()); @@ -129,7 +132,7 @@ fn copy_from_hook(src: ByondValue, giver: ByondValue) { } /// Args: (src, mixture, conductivity) or (src, conductivity, temperature, heat_capacity). Adjusts temperature of src based on parameters. Returns: temperature of sharer after sharing is complete. -#[byondapi_binds::bind_raw_args("/datum/gas_mixture/proc/temperature_share")] +#[byondapi::bind_raw_args("/datum/gas_mixture/proc/temperature_share")] fn temperature_share_hook() { let arg_num = args.len(); match arg_num { @@ -152,7 +155,7 @@ fn temperature_share_hook() { } /// Returns: a list of the gases in the mixture, associated with their IDs. -#[byondapi_binds::bind("/datum/gas_mixture/proc/get_gases")] +#[byondapi::bind("/datum/gas_mixture/proc/get_gases")] fn get_gases_hook(src: ByondValue) { with_mix(&src, |mix| { let mut gases_list = ByondValue::new_list()?; @@ -168,7 +171,7 @@ fn get_gases_hook(src: ByondValue) { } /// Args: (temperature). Sets the temperature of the mixture. Will be set to 2.7 if it's too low. -#[byondapi_binds::bind("/datum/gas_mixture/proc/set_temperature")] +#[byondapi::bind("/datum/gas_mixture/proc/set_temperature")] fn set_temperature_hook(src: ByondValue, arg_temp: ByondValue) { let v = arg_temp.get_number()?; if v.is_finite() { @@ -184,7 +187,7 @@ fn set_temperature_hook(src: ByondValue, arg_temp: ByondValue) { } /// Args: (gas_id). Returns the heat capacity from the given gas, in J/K (probably). -#[byondapi_binds::bind("/datum/gas_mixture/proc/partial_heat_capacity")] +#[byondapi::bind("/datum/gas_mixture/proc/partial_heat_capacity")] fn partial_heat_capacity(src: ByondValue, gas_id: ByondValue) { with_mix(&src, |mix| { Ok(mix @@ -194,7 +197,7 @@ fn partial_heat_capacity(src: ByondValue, gas_id: ByondValue) { } /// Args: (volume). Sets the volume of the gas. -#[byondapi_binds::bind("/datum/gas_mixture/proc/set_volume")] +#[byondapi::bind("/datum/gas_mixture/proc/set_volume")] fn set_volume_hook(src: ByondValue, vol_arg: ByondValue) { let volume = vol_arg.get_number()?; with_mix_mut(&src, |mix| { @@ -204,7 +207,7 @@ fn set_volume_hook(src: ByondValue, vol_arg: ByondValue) { } /// Args: (gas_id). Returns: the amount of substance of the given gas, in moles. -#[byondapi_binds::bind("/datum/gas_mixture/proc/get_moles")] +#[byondapi::bind("/datum/gas_mixture/proc/get_moles")] fn get_moles_hook(src: ByondValue, gas_id: ByondValue) { with_mix(&src, |mix| { Ok(mix.get_moles(gas_idx_from_value(&gas_id)?).into()) @@ -212,7 +215,7 @@ fn get_moles_hook(src: ByondValue, gas_id: ByondValue) { } /// Args: (gas_id, moles). Sets the amount of substance of the given gas, in moles. -#[byondapi_binds::bind("/datum/gas_mixture/proc/set_moles")] +#[byondapi::bind("/datum/gas_mixture/proc/set_moles")] fn set_moles_hook(src: ByondValue, gas_id: ByondValue, amt_val: ByondValue) { let vf = amt_val.get_number()?; if !vf.is_finite() { @@ -227,7 +230,7 @@ fn set_moles_hook(src: ByondValue, gas_id: ByondValue, amt_val: ByondValue) { }) } /// Args: (gas_id, moles). Adjusts the given gas's amount by the given amount, e.g. (GAS_O2, -0.1) will remove 0.1 moles of oxygen from the mixture. -#[byondapi_binds::bind("/datum/gas_mixture/proc/adjust_moles")] +#[byondapi::bind("/datum/gas_mixture/proc/adjust_moles")] fn adjust_moles_hook(src: ByondValue, id_val: ByondValue, num_val: ByondValue) { let vf = num_val.get_number().unwrap_or_default(); with_mix_mut(&src, |mix| { @@ -237,7 +240,7 @@ fn adjust_moles_hook(src: ByondValue, id_val: ByondValue, num_val: ByondValue) { } /// Args: (gas_id, moles, temp). Adjusts the given gas's amount by the given amount, with that gas being treated as if it is at the given temperature. -#[byondapi_binds::bind("/datum/gas_mixture/proc/adjust_moles_temp")] +#[byondapi::bind("/datum/gas_mixture/proc/adjust_moles_temp")] fn adjust_moles_temp_hook( src: ByondValue, id_val: ByondValue, @@ -264,7 +267,7 @@ fn adjust_moles_temp_hook( } /// Args: (gas_id_1, amount_1, gas_id_2, amount_2, ...). As adjust_moles, but with variadic arguments. -#[byondapi_binds::bind_raw_args("/datum/gas_mixture/proc/adjust_multi")] +#[byondapi::bind_raw_args("/datum/gas_mixture/proc/adjust_multi")] fn adjust_multi_hook() { if args.len() % 2 == 0 { Err(eyre::eyre!( @@ -293,7 +296,7 @@ fn adjust_multi_hook() { } ///Args: (amount). Adds the given amount to each gas. -#[byondapi_binds::bind("/datum/gas_mixture/proc/add")] +#[byondapi::bind("/datum/gas_mixture/proc/add")] fn add_hook(src: ByondValue, num_val: ByondValue) { let vf = num_val.get_number().unwrap_or_default(); with_mix_mut(&src, |mix| { @@ -303,7 +306,7 @@ fn add_hook(src: ByondValue, num_val: ByondValue) { } ///Args: (amount). Subtracts the given amount from each gas. -#[byondapi_binds::bind("/datum/gas_mixture/proc/subtract")] +#[byondapi::bind("/datum/gas_mixture/proc/subtract")] fn subtract_hook(src: ByondValue, num_val: ByondValue) { let vf = num_val.get_number().unwrap_or_default(); with_mix_mut(&src, |mix| { @@ -313,7 +316,7 @@ fn subtract_hook(src: ByondValue, num_val: ByondValue) { } ///Args: (coefficient). Multiplies all gases by this amount. -#[byondapi_binds::bind("/datum/gas_mixture/proc/multiply")] +#[byondapi::bind("/datum/gas_mixture/proc/multiply")] fn multiply_hook(src: ByondValue, num_val: ByondValue) { let vf = num_val.get_number().unwrap_or(1.0); with_mix_mut(&src, |mix| { @@ -323,7 +326,7 @@ fn multiply_hook(src: ByondValue, num_val: ByondValue) { } ///Args: (coefficient). Divides all gases by this amount. -#[byondapi_binds::bind("/datum/gas_mixture/proc/divide")] +#[byondapi::bind("/datum/gas_mixture/proc/divide")] fn divide_hook(src: ByondValue, num_val: ByondValue) { let vf = num_val.get_number().unwrap_or(1.0).recip(); with_mix_mut(&src, |mix| { @@ -333,7 +336,7 @@ fn divide_hook(src: ByondValue, num_val: ByondValue) { } ///Args: (mixture, flag, amount). Takes `amount` from src that have the given `flag` and puts them into the given `mixture`. Returns: 0 if gas didn't have any with that flag, 1 if it did. -#[byondapi_binds::bind("/datum/gas_mixture/proc/__remove_by_flag")] +#[byondapi::bind("/datum/gas_mixture/proc/__remove_by_flag")] fn remove_by_flag_hook( src: ByondValue, into: ByondValue, @@ -359,7 +362,7 @@ fn remove_by_flag_hook( }) } ///Args: (flag). As get_gases(), but only returns gases with the given flag. -#[byondapi_binds::bind("/datum/gas_mixture/proc/get_by_flag")] +#[byondapi::bind("/datum/gas_mixture/proc/get_by_flag")] fn get_by_flag_hook(src: ByondValue, flag_val: ByondValue) { let flag = flag_val.get_number().map_or(0, |n: f32| n as u32); let pertinent_gases = with_gas_info(|gas_info| { @@ -381,7 +384,7 @@ fn get_by_flag_hook(src: ByondValue, flag_val: ByondValue) { } /// Args: (mixture, ratio, gas_list). Takes gases given by `gas_list` and moves `ratio` amount of those gases from `src` into `mixture`. -#[byondapi_binds::bind("/datum/gas_mixture/proc/scrub_into")] +#[byondapi::bind("/datum/gas_mixture/proc/scrub_into")] fn scrub_into_hook(src: ByondValue, into: ByondValue, ratio_v: ByondValue, gas_list: ByondValue) { let ratio = ratio_v.get_number()?; if !gas_list.is_list() { @@ -401,7 +404,7 @@ fn scrub_into_hook(src: ByondValue, into: ByondValue, ratio_v: ByondValue, gas_l } /// Marks the mix as immutable, meaning it will never change. This cannot be undone. -#[byondapi_binds::bind("/datum/gas_mixture/proc/mark_immutable")] +#[byondapi::bind("/datum/gas_mixture/proc/mark_immutable")] fn mark_immutable_hook(src: ByondValue) { with_mix_mut(&src, |mix| { mix.mark_immutable(); @@ -410,7 +413,7 @@ fn mark_immutable_hook(src: ByondValue) { } /// Clears the gas mixture my removing all of its gases. -#[byondapi_binds::bind("/datum/gas_mixture/proc/clear")] +#[byondapi::bind("/datum/gas_mixture/proc/clear")] fn clear_hook(src: ByondValue) { with_mix_mut(&src, |mix| { mix.clear(); @@ -419,7 +422,7 @@ fn clear_hook(src: ByondValue) { } /// Returns: true if the two mixtures are different enough for processing, false otherwise. -#[byondapi_binds::bind("/datum/gas_mixture/proc/compare")] +#[byondapi::bind("/datum/gas_mixture/proc/compare")] fn compare_hook(src: ByondValue, other: ByondValue) { with_mixes(&src, &other, |gas_one, gas_two| { Ok((gas_one.temperature_compare(gas_two) @@ -429,7 +432,7 @@ fn compare_hook(src: ByondValue, other: ByondValue) { } /// Args: (holder). Runs all reactions on this gas mixture. Holder is used by the reactions, and can be any arbitrary datum or null. -#[byondapi_binds::bind("/datum/gas_mixture/proc/react")] +#[byondapi::bind("/datum/gas_mixture/proc/react")] fn react_hook(src: ByondValue, holder: ByondValue) { let mut ret = ReactionReturn::NO_REACTION; let reactions = with_mix(&src, |mix| Ok(mix.all_reactable()))?; @@ -447,7 +450,7 @@ fn react_hook(src: ByondValue, holder: ByondValue) { } /// Args: (heat). Adds a given amount of heat to the mixture, i.e. in joules taking into account capacity. -#[byondapi_binds::bind("/datum/gas_mixture/proc/adjust_heat")] +#[byondapi::bind("/datum/gas_mixture/proc/adjust_heat")] fn adjust_heat_hook(src: ByondValue, temp: ByondValue) { with_mix_mut(&src, |mix| { mix.adjust_heat(temp.get_number()?); @@ -456,7 +459,7 @@ fn adjust_heat_hook(src: ByondValue, temp: ByondValue) { } /// Args: (mixture, amount). Takes the `amount` given and transfers it from `src` to `mixture`. -#[byondapi_binds::bind("/datum/gas_mixture/proc/transfer_to")] +#[byondapi::bind("/datum/gas_mixture/proc/transfer_to")] fn transfer_hook(src: ByondValue, other: ByondValue, moles: ByondValue) { with_mixes_mut(&src, &other, |our_mix, other_mix| { other_mix.merge(&our_mix.remove(moles.get_number()?)); @@ -465,7 +468,7 @@ fn transfer_hook(src: ByondValue, other: ByondValue, moles: ByondValue) { } /// Args: (mixture, ratio). Transfers `ratio` of `src` to `mixture`. -#[byondapi_binds::bind("/datum/gas_mixture/proc/transfer_ratio_to")] +#[byondapi::bind("/datum/gas_mixture/proc/transfer_ratio_to")] fn transfer_ratio_hook(src: ByondValue, other: ByondValue, ratio: ByondValue) { with_mixes_mut(&src, &other, |our_mix, other_mix| { other_mix.merge(&our_mix.remove_ratio(ratio.get_number()?)); @@ -474,7 +477,7 @@ fn transfer_ratio_hook(src: ByondValue, other: ByondValue, ratio: ByondValue) { } /// Args: (mixture). Makes `src` a copy of `mixture`, with volumes taken into account. -#[byondapi_binds::bind("/datum/gas_mixture/proc/equalize_with")] +#[byondapi::bind("/datum/gas_mixture/proc/equalize_with")] fn equalize_with_hook(src: ByondValue, total: ByondValue) { with_mixes_custom(&src, &total, |src_lock, total_lock| { let src_gas = &mut src_lock.write(); @@ -487,7 +490,7 @@ fn equalize_with_hook(src: ByondValue, total: ByondValue) { } /// Args: (temperature). Returns: how much fuel for fire is in the mixture at the given temperature. If temperature is omitted, just uses current temperature instead. -#[byondapi_binds::bind("/datum/gas_mixture/proc/get_fuel_amount")] +#[byondapi::bind("/datum/gas_mixture/proc/get_fuel_amount")] fn fuel_amount_hook(src: ByondValue, temp: ByondValue) { with_mix(&src, |air| { Ok(temp @@ -506,7 +509,7 @@ fn fuel_amount_hook(src: ByondValue, temp: ByondValue) { } /// Args: (temperature). Returns: how much oxidizer for fire is in the mixture at the given temperature. If temperature is omitted, just uses current temperature instead. -#[byondapi_binds::bind("/datum/gas_mixture/proc/get_oxidation_power")] +#[byondapi::bind("/datum/gas_mixture/proc/get_oxidation_power")] fn oxidation_power_hook(src: ByondValue, temp: ByondValue) { with_mix(&src, |air| { Ok(temp @@ -526,7 +529,7 @@ fn oxidation_power_hook(src: ByondValue, temp: ByondValue) { /// Args: (mixture, ratio, one_way). Shares the given `ratio` of `src` with `mixture`, and, unless `one_way` is truthy, vice versa. #[cfg(feature = "zas_hooks")] -#[byondapi_binds::bind("/datum/gas_mixture/proc/share_ratio")] +#[byondapi::bind("/datum/gas_mixture/proc/share_ratio")] fn share_ratio_hook(other_gas: ByondValue, ratio_val: ByondValue, one_way_val: ByondValue) { let one_way = one_way_val.as_bool().unwrap_or(false); let ratio = ratio_val.as_number().ok().map_or(0.6); @@ -561,7 +564,7 @@ fn share_ratio_hook(other_gas: ByondValue, ratio_val: ByondValue, one_way_val: B } /// Args: (list). Takes every gas in the list and makes them all identical, scaled to their respective volumes. The total heat and amount of substance in all of the combined gases is conserved. -#[byondapi_binds::bind("/proc/equalize_all_gases_in_list")] +#[byondapi::bind("/proc/equalize_all_gases_in_list")] fn equalize_all_hook(gas_list: ByondValue) { use std::collections::BTreeSet; let gas_list = gas_list @@ -600,18 +603,18 @@ fn equalize_all_hook(gas_list: ByondValue) { } /// Returns: the amount of gas mixtures that are attached to a byond gas mixture. -#[byondapi_binds::bind("/datum/controller/subsystem/air/proc/get_amt_gas_mixes")] +#[byondapi::bind("/datum/controller/subsystem/air/proc/get_amt_gas_mixes")] fn hook_amt_gas_mixes() { Ok((amt_gases() as f32).into()) } /// Returns: the total amount of gas mixtures in the arena, including "free" ones. -#[byondapi_binds::bind("/datum/controller/subsystem/air/proc/get_max_gas_mixes")] +#[byondapi::bind("/datum/controller/subsystem/air/proc/get_max_gas_mixes")] fn hook_max_gas_mixes() { Ok((tot_gases() as f32).into()) } -#[byondapi_binds::bind("/datum/gas_mixture/proc/__auxtools_parse_gas_string")] +#[byondapi::bind("/datum/gas_mixture/proc/__auxtools_parse_gas_string")] fn parse_gas_string(src: ByondValue, string: ByondValue) { let actual_string = string.get_string()?; @@ -642,5 +645,5 @@ fn parse_gas_string(src: ByondValue, string: ByondValue) { #[test] fn generate_binds() { - byondapi_binds::generate_bindings(); + byondapi::generate_bindings(env!("CARGO_CRATE_NAME")); } diff --git a/src/parser.rs b/src/parser.rs index 0c5a795f..0decf504 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -19,7 +19,7 @@ fn parse_moles(input: &str) -> IResult<&str, f32> { /// Parses gas strings, invalid patterns will be ignored /// E.g: "o2=2500;plasma=5000;TEMP=370" will return vec![("o2", 2500_f32), ("plasma", 5000_f32), ("TEMP", 370_f32)] -pub fn parse_gas_string(input: &str) -> IResult<&str, Vec<(&str, f32)>> { +pub(crate) fn parse_gas_string(input: &str) -> IResult<&str, Vec<(&str, f32)>> { separated_list0( tag(";"), separated_pair(parse_gas_id, tag("="), parse_moles), diff --git a/src/turfs.rs b/src/turfs.rs index 529c53dd..a06923d0 100644 --- a/src/turfs.rs +++ b/src/turfs.rs @@ -380,7 +380,7 @@ pub fn wait_for_tasks() { ), } } - +#[byondapi::init] pub fn initialize_turfs() { // 10x 255x255 zlevels // double that for edges since each turf can have up to 6 edges but eehhhh @@ -420,12 +420,12 @@ where fn with_planetary_atmos_upgradeable_read(f: F) -> T where - F: FnOnce(RwLockUpgradableReadGuard>>) -> T, + F: FnOnce(RwLockUpgradableReadGuard<'_, Option>>) -> T, { f(PLANETARY_ATMOS.upgradable_read()) } -#[byondapi_binds::bind("/turf/proc/update_air_ref")] +#[byondapi::bind("/turf/proc/update_air_ref")] fn hook_register_turf(src: ByondValue, flag: ByondValue) { let id = src.get_ref()?; let flag = flag.get_number()? as i32; @@ -505,7 +505,7 @@ fn determine_turf_flag(src: &ByondValue) -> i32 { } */ -#[byondapi_binds::bind("/turf/proc/__update_auxtools_turf_adjacency_info")] +#[byondapi::bind("/turf/proc/__update_auxtools_turf_adjacency_info")] fn hook_infos(src: ByondValue) { let id = src.get_ref()?; with_turf_gases_write(|arena| -> Result<()> { diff --git a/src/turfs/groups.rs b/src/turfs/groups.rs index 18a8030d..0efc3ac6 100644 --- a/src/turfs/groups.rs +++ b/src/turfs/groups.rs @@ -20,7 +20,7 @@ pub fn send_to_groups(sent: BTreeSet) { GROUPS_CHANNEL.try_lock().map(|mut opt| opt.replace(sent)); } -#[byondapi_binds::bind("/datum/controller/subsystem/air/proc/process_excited_groups_auxtools")] +#[byondapi::bind("/datum/controller/subsystem/air/proc/process_excited_groups_auxtools")] fn groups_hook(mut src: ByondValue, remaining: ByondValue) { let group_pressure_goal = src .read_number_id(byond_string!("excited_group_pressure_goal")) diff --git a/src/turfs/katmos.rs b/src/turfs/katmos.rs index 97623099..439a1600 100644 --- a/src/turfs/katmos.rs +++ b/src/turfs/katmos.rs @@ -719,7 +719,7 @@ fn send_pressure_differences( } } -#[byondapi_binds::bind("/datum/controller/subsystem/air/proc/process_turf_equalize_auxtools")] +#[byondapi::bind("/datum/controller/subsystem/air/proc/process_turf_equalize_auxtools")] fn equalize_hook(mut src: ByondValue, remaining: ByondValue) { let equalize_hard_turf_limit = src .read_number_id(byond_string!("equalize_hard_turf_limit")) diff --git a/src/turfs/processing.rs b/src/turfs/processing.rs index ed1a953f..cedb54ae 100644 --- a/src/turfs/processing.rs +++ b/src/turfs/processing.rs @@ -14,17 +14,17 @@ use std::collections::{BTreeMap, BTreeSet}; use coarsetime::{Duration, Instant}; -#[byondapi_binds::bind("/datum/controller/subsystem/air/proc/thread_running")] +#[byondapi::bind("/datum/controller/subsystem/air/proc/thread_running")] fn thread_running_hook() { Ok(TASKS.try_write().is_none().into()) } -#[byondapi_binds::bind("/datum/controller/subsystem/air/proc/finish_turf_processing_auxtools")] +#[byondapi::bind("/datum/controller/subsystem/air/proc/finish_turf_processing_auxtools")] fn finish_process_turfs(time_remaining: ByondValue) { Ok(process_callbacks_for_millis(time_remaining.get_number()? as u64).into()) } -#[byondapi_binds::bind("/datum/controller/subsystem/air/proc/process_turfs_auxtools")] +#[byondapi::bind("/datum/controller/subsystem/air/proc/process_turfs_auxtools")] fn process_turf_hook(src: ByondValue, remaining: ByondValue) { let remaining_time = Duration::from_millis(remaining.get_number().unwrap_or(50.0) as u64); let fdm_max_steps = src