From a76044c1b4ad8b0ef1172de99897695324c80ec9 Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Tue, 31 Oct 2023 19:18:06 +0800 Subject: [PATCH] Update Cargo.lock, cxx.h, fmt ffi --- lib/Cargo.lock | 299 ++++++----- make.sh | 2 +- src/.clang-format | 2 +- src/ffi/cxx.h | 1261 ++++++++++++++++++++++----------------------- 4 files changed, 772 insertions(+), 792 deletions(-) diff --git a/lib/Cargo.lock b/lib/Cargo.lock index b23504da49..a7e4e9ccad 100644 --- a/lib/Cargo.lock +++ b/lib/Cargo.lock @@ -631,9 +631,9 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "2.5.0" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da74e2b81409b1b743f8f0c62cc6254afefb8b8e50bbfe3735550f7aeefa3448" +checksum = "4e2e4afe60d7dd600fdd3de8d0f08c2b7ec039712e3b6137ff98b7004e82de4f" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -801,13 +801,14 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.9.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c37be52ef5e3b394db27a2341010685ad5103c72ac15ce2e9420a7e8f93f342c" +checksum = "a5104de16b218eddf8e34ffe2f86f74bfa4e61e95a1b89732fccf6325efd0557" dependencies = [ "cfg-if", "cpufeatures", "hex", + "proptest", "serde", ] @@ -856,9 +857,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fbc60abd742b35f2492f808e1abbb83d45f72db402e14c55057edc9c7b1e9e4" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] @@ -990,9 +991,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.109" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c390c123d671cc547244943ecad81bdaab756c6ea332d9ca9c1f48d952a24895" +checksum = "7129e341034ecb940c9072817cd9007974ea696844fc4dd582dc1653a7fbe2e8" dependencies = [ "cc", "cxxbridge-flags", @@ -1002,9 +1003,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.109" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00d3d3ac9ffb900304edf51ca719187c779f4001bb544f26c4511d621de905cf" +checksum = "a2a24f3f5f8eed71936f21e570436f024f5c2e25628f7496aa7ccd03b90109d5" dependencies = [ "cc", "codespan-reporting", @@ -1017,9 +1018,9 @@ dependencies = [ [[package]] name = "cxx-gen" -version = "0.7.109" +version = "0.7.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1318697052dbc5a12f8e5e603441413d6096350c29b8361eb45a9c531be61dda" +checksum = "a3e0fc77e9f8d61724be90deb42a7e50ba3bf37c7c16dc91cdba821f69a5e0e9" dependencies = [ "codespan-reporting", "proc-macro2", @@ -1029,15 +1030,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.109" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94415827ecfea0f0c74c8cad7d1a86ddb3f05354d6a6ddeda0adee5e875d2939" +checksum = "06fdd177fc61050d63f67f5bd6351fac6ab5526694ea8e359cd9cd3b75857f44" [[package]] name = "cxxbridge-macro" -version = "1.0.109" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33dbbe9f5621c9247f97ec14213b04f350bff4b6cebefe834c60055db266ecf" +checksum = "587663dd5fb3d10932c8aecfe7c844db1bcf0aee93eeab08fac13dc1212c2e7f" dependencies = [ "proc-macro2", "quote", @@ -1110,6 +1111,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "deunicode" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a1abaf4d861455be59f64fd2b55606cb151fce304ede7165f410243ce96bde6" + [[package]] name = "diff" version = "0.1.13" @@ -1543,12 +1550,12 @@ dependencies = [ [[package]] name = "fake" -version = "2.8.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9af7b0c58ac9d03169e27f080616ce9f64004edca3d2ef4147a811c21b23b319" +checksum = "26221445034074d46b276e13eb97a265ebdb8ed8da705c4dddd3dd20b66b45d2" dependencies = [ + "deunicode", "rand 0.8.5", - "unidecode", ] [[package]] @@ -1656,9 +1663,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" dependencies = [ "futures-channel", "futures-core", @@ -1671,9 +1678,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" dependencies = [ "futures-core", "futures-sink", @@ -1681,15 +1688,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" dependencies = [ "futures-core", "futures-task", @@ -1699,15 +1706,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", @@ -1716,21 +1723,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ "futures-channel", "futures-core", @@ -2073,9 +2080,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http", @@ -2085,7 +2092,7 @@ dependencies = [ "rustls-native-certs", "tokio", "tokio-rustls", - "webpki-roots 0.23.1", + "webpki-roots", ] [[package]] @@ -2242,7 +2249,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi 0.3.3", - "rustix 0.38.20", + "rustix 0.38.21", "windows-sys 0.48.0", ] @@ -2403,7 +2410,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44e8ab85614a08792b9bff6c8feee23be78c98d0182d4c622c05256ab553892a" dependencies = [ "heck 0.4.1", - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 1.0.109", @@ -2764,7 +2771,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" dependencies = [ - "rustix 0.38.20", + "rustix 0.38.21", ] [[package]] @@ -3019,20 +3026,20 @@ dependencies = [ [[package]] name = "num_enum" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70bf6736f74634d299d00086f02986875b3c2d924781a6a2cb6c201e73da0ceb" +checksum = "683751d591e6d81200c39fb0d1032608b77724f34114db54f571ff1317b337c0" dependencies = [ "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56ea360eafe1022f7cc56cd7b869ed57330fb2453d0c7831d99b74c65d2f5597" +checksum = "6c11e44798ad209ccdd91fc192f0526a369a01234f7373e1b141c96d7cee4f0e" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 2.0.0", "proc-macro2", "quote", "syn 2.0.38", @@ -3135,7 +3142,7 @@ version = "3.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 1.0.109", @@ -3388,7 +3395,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "toml_edit", + "toml_edit 0.19.15", +] + +[[package]] +name = "proc-macro-crate" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" +dependencies = [ + "toml_edit 0.20.7", ] [[package]] @@ -3424,6 +3440,22 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "proptest" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c003ac8c77cb07bb74f5f198bce836a689bcd5a42574612bf14d17bfd08c20e" +dependencies = [ + "bitflags 2.4.1", + "lazy_static", + "num-traits", + "rand 0.8.5", + "rand_chacha 0.3.1", + "rand_xorshift", + "regex-syntax 0.7.5", + "unarray", +] + [[package]] name = "prost" version = "0.11.9" @@ -3611,6 +3643,15 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "rand_xorshift" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" +dependencies = [ + "rand_core 0.6.4", +] + [[package]] name = "rawpointer" version = "0.2.1" @@ -3655,15 +3696,6 @@ dependencies = [ "bitflags 1.3.2", ] -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_syscall" version = "0.4.1" @@ -3799,7 +3831,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "webpki-roots 0.25.2", + "webpki-roots", "winreg", ] @@ -3813,21 +3845,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "ring" -version = "0.16.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" -dependencies = [ - "cc", - "libc", - "once_cell", - "spin 0.5.2", - "untrusted 0.7.1", - "web-sys", - "winapi", -] - [[package]] name = "ring" version = "0.17.5" @@ -3838,7 +3855,7 @@ dependencies = [ "getrandom 0.2.10", "libc", "spin 0.9.8", - "untrusted 0.9.0", + "untrusted", "windows-sys 0.48.0", ] @@ -3932,9 +3949,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.16" +version = "0.36.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6da3636faa25820d8648e0e31c5d519bbb01f72fdf57131f0f5f7da5fed36eab" +checksum = "305efbd14fde4139eb501df5f136994bb520b033fa9fbdce287507dc23b8c7ed" dependencies = [ "bitflags 1.3.2", "errno", @@ -3946,9 +3963,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.20" +version = "0.38.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ce50cb2e16c2903e30d1cbccfd8387a74b9d4c938b6a4c5ec6cc7556f7a8a0" +checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" dependencies = [ "bitflags 2.4.1", "errno", @@ -3964,8 +3981,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" dependencies = [ "log", - "ring 0.17.5", - "rustls-webpki 0.101.7", + "ring", + "rustls-webpki", "sct", ] @@ -3990,24 +4007,14 @@ dependencies = [ "base64 0.21.5", ] -[[package]] -name = "rustls-webpki" -version = "0.100.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f6a5fc258f1c1276dfe3016516945546e2d5383911efc0fc4f1cdc5df3a4ae3" -dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", -] - [[package]] name = "rustls-webpki" version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring 0.17.5", - "untrusted 0.9.0", + "ring", + "untrusted", ] [[package]] @@ -4060,7 +4067,7 @@ version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 1.0.109", @@ -4122,8 +4129,8 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "ring 0.17.5", - "untrusted 0.9.0", + "ring", + "untrusted", ] [[package]] @@ -4216,18 +4223,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.189" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" +checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.189" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" +checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" dependencies = [ "proc-macro2", "quote", @@ -4236,9 +4243,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.107" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", @@ -4630,7 +4637,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7402572a08aa1ae421ea5bab10918764b0ae72301b27710913e5d804862f2448" dependencies = [ "Inflector", - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 2.0.38", @@ -4867,9 +4874,9 @@ dependencies = [ [[package]] name = "substrate-bip39" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49eee6965196b32f882dd2ee85a92b1dbead41b04e53907f269de3b0dc04733c" +checksum = "e620c7098893ba667438b47169c00aacdd9e7c10e042250ce2b60b087ec97328" dependencies = [ "hmac 0.11.0", "pbkdf2 0.8.0", @@ -4899,9 +4906,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "svm-rs" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597e3a746727984cb7ea2487b6a40726cad0dbe86628e7d429aa6b8c4c153db4" +checksum = "d0cc95be7cc2c384a2f57cac56548d2178650905ebe5725bc8970ccc25529060" dependencies = [ "dirs", "fs2", @@ -4990,14 +4997,14 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", "fastrand", - "redox_syscall 0.3.5", - "rustix 0.38.20", + "redox_syscall 0.4.1", + "rustix 0.38.21", "windows-sys 0.48.0", ] @@ -5202,9 +5209,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ "bytes", "futures-core", @@ -5232,6 +5239,17 @@ dependencies = [ "winnow", ] +[[package]] +name = "toml_edit" +version = "0.20.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" +dependencies = [ + "indexmap 2.0.2", + "toml_datetime", + "winnow", +] + [[package]] name = "tonic" version = "0.9.2" @@ -5479,6 +5497,12 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "unarray" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" + [[package]] name = "unicase" version = "2.7.0" @@ -5527,18 +5551,6 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" -[[package]] -name = "unidecode" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "402bb19d8e03f1d1a7450e2bd613980869438e0666331be3e073089124aa1adc" - -[[package]] -name = "untrusted" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" - [[package]] name = "untrusted" version = "0.9.0" @@ -5646,9 +5658,8 @@ dependencies = [ [[package]] name = "vsdbsled" -version = "0.34.7-p1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b42602d283268f887952376e41ce60f5ab5f79e8725dab731de4ab1b0e70e53" +version = "0.34.8" +source = "git+https://github.com/defich/vsdbsled.git#a20d135447652d6d8ca97ce5830267515a7322e6" dependencies = [ "crc32fast", "crossbeam-epoch", @@ -5881,7 +5892,7 @@ dependencies = [ "memoffset 0.8.0", "paste", "rand 0.8.5", - "rustix 0.36.16", + "rustix 0.36.17", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", @@ -5910,15 +5921,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki-roots" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" -dependencies = [ - "rustls-webpki 0.100.3", -] - [[package]] name = "webpki-roots" version = "0.25.2" @@ -5934,7 +5936,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.20", + "rustix 0.38.21", ] [[package]] @@ -6121,9 +6123,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.17" +version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3b801d0e0a6726477cc207f60162da452f3a95adb368399bef20a946e06f65c" +checksum = "176b6138793677221d420fd2f0aeeced263f197688b36484660da767bca2fa32" dependencies = [ "memchr", ] @@ -6155,18 +6157,18 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "zerocopy" -version = "0.7.14" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69c48d63854f77746c68a5fbb4aa17f3997ece1cb301689a257af8cb80610d21" +checksum = "dd66a62464e3ffd4e37bd09950c2b9dd6c4f8767380fabba0d523f9a775bc85a" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.14" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c258c1040279e4f88763a113de72ce32dde2d50e2a94573f15dd534cea36a16d" +checksum = "255c4596d41e6916ced49cfafea18727b24d67878fa180ddfd69b9df34fd1726" dependencies = [ "proc-macro2", "quote", @@ -6259,8 +6261,3 @@ dependencies = [ "cc", "pkg-config", ] - -[[patch.unused]] -name = "vsdbsled" -version = "0.34.8" -source = "git+https://github.com/defich/vsdbsled.git#a20d135447652d6d8ca97ce5830267515a7322e6" diff --git a/make.sh b/make.sh index 00b72509a1..3be9e75bf4 100755 --- a/make.sh +++ b/make.sh @@ -475,7 +475,7 @@ _run_clang_format() { fi # shellcheck disable=SC2086 - find src/dfi \( -iname "*.cpp" -o -iname "*.h" \) -print0 | \ + find src/dfi src/ffi \( -iname "*.cpp" -o -iname "*.h" \) -print0 | \ xargs -0 -I{} "${clang_formatters[$index]}" $fmt_args -i -style=file {} local whitelist_files=(src/miner.{cpp,h} src/txmempool.{cpp,h} src/validation.{cpp,h}) diff --git a/src/.clang-format b/src/.clang-format index a4e3c6d888..ab5d61dad6 100644 --- a/src/.clang-format +++ b/src/.clang-format @@ -119,7 +119,7 @@ LambdaBodyIndentation: Signature MacroBlockBegin: '' MacroBlockEnd: '' MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None +NamespaceIndentation: All ObjCBinPackProtocolList: Never ObjCBlockIndentWidth: 2 ObjCBreakBeforeNestedBlockParam: true diff --git a/src/ffi/cxx.h b/src/ffi/cxx.h index 11fe33b249..1fc163b2d8 100644 --- a/src/ffi/cxx.h +++ b/src/ffi/cxx.h @@ -34,7 +34,7 @@ namespace rust { #ifndef CXXBRIDGE1_RUST_STRING #define CXXBRIDGE1_RUST_STRING -// https://cxx.rs/binding/string.html + // https://cxx.rs/binding/string.html class String final { public: String() noexcept; @@ -102,11 +102,11 @@ namespace rust { // Size and alignment statically verified by rust_string.rs. std::array repr; }; -#endif // CXXBRIDGE1_RUST_STRING +#endif // CXXBRIDGE1_RUST_STRING #ifndef CXXBRIDGE1_RUST_STR #define CXXBRIDGE1_RUST_STR -// https://cxx.rs/binding/str.html + // https://cxx.rs/binding/str.html class Str final { public: Str() noexcept; @@ -152,7 +152,7 @@ namespace rust { std::array repr; }; -#endif // CXXBRIDGE1_RUST_STR +#endif // CXXBRIDGE1_RUST_STR #ifndef CXXBRIDGE1_RUST_SLICE namespace detail { @@ -166,12 +166,11 @@ namespace rust { copy_assignable_if &operator=(const copy_assignable_if &) &noexcept = delete; copy_assignable_if &operator=(copy_assignable_if &&) &noexcept = default; }; - } // namespace detail + } // namespace detail -// https://cxx.rs/binding/slice.html + // https://cxx.rs/binding/slice.html template - class Slice final - : private detail::copy_assignable_if::value> { + class Slice final : private detail::copy_assignable_if::value> { public: using value_type = T; @@ -248,16 +247,15 @@ namespace rust { void *pos; std::size_t stride; }; -#endif // CXXBRIDGE1_RUST_SLICE +#endif // CXXBRIDGE1_RUST_SLICE #ifndef CXXBRIDGE1_RUST_BOX -// https://cxx.rs/binding/box.html + // https://cxx.rs/binding/box.html template class Box final { public: using element_type = T; - using const_pointer = - typename std::add_pointer::type>::type; + using const_pointer = typename std::add_pointer::type>::type; using pointer = typename std::add_pointer::type; Box() = delete; @@ -297,10 +295,10 @@ namespace rust { T *ptr; }; -#endif // CXXBRIDGE1_RUST_BOX +#endif // CXXBRIDGE1_RUST_BOX #ifndef CXXBRIDGE1_RUST_VEC -// https://cxx.rs/binding/vec.html + // https://cxx.rs/binding/vec.html template class Vec final { public: @@ -364,10 +362,10 @@ namespace rust { // Size and alignment statically verified by rust_vec.rs. std::array repr; }; -#endif // CXXBRIDGE1_RUST_VEC +#endif // CXXBRIDGE1_RUST_VEC #ifndef CXXBRIDGE1_RUST_FN -// https://cxx.rs/binding/fn.html + // https://cxx.rs/binding/fn.html template class Fn; @@ -381,11 +379,11 @@ namespace rust { Ret (*trampoline)(Args..., void *fn) noexcept; void *fn; }; -#endif // CXXBRIDGE1_RUST_FN +#endif // CXXBRIDGE1_RUST_FN #ifndef CXXBRIDGE1_RUST_ERROR #define CXXBRIDGE1_RUST_ERROR -// https://cxx.rs/binding/result.html + // https://cxx.rs/binding/result.html class Error final : public std::exception { public: Error(const Error &); @@ -403,7 +401,7 @@ namespace rust { const char *msg; std::size_t len; }; -#endif // CXXBRIDGE1_RUST_ERROR +#endif // CXXBRIDGE1_RUST_ERROR #ifndef CXXBRIDGE1_RUST_ISIZE #define CXXBRIDGE1_RUST_ISIZE @@ -412,45 +410,45 @@ namespace rust { #else using isize = ssize_t; #endif -#endif // CXXBRIDGE1_RUST_ISIZE +#endif // CXXBRIDGE1_RUST_ISIZE std::ostream &operator<<(std::ostream &, const String &); std::ostream &operator<<(std::ostream &, const Str &); #ifndef CXXBRIDGE1_RUST_OPAQUE #define CXXBRIDGE1_RUST_OPAQUE -// Base class of generated opaque Rust types. + // Base class of generated opaque Rust types. class Opaque { public: Opaque() = delete; Opaque(const Opaque &) = delete; ~Opaque() = delete; }; -#endif // CXXBRIDGE1_RUST_OPAQUE +#endif // CXXBRIDGE1_RUST_OPAQUE template std::size_t size_of(); template std::size_t align_of(); -// IsRelocatable is used in assertions that a C++ type passed by value -// between Rust and C++ is soundly relocatable by Rust. -// -// There may be legitimate reasons to opt out of the check for support of types -// that the programmer knows are soundly Rust-movable despite not being -// recognized as such by the C++ type system due to a move constructor or -// destructor. To opt out of the relocatability check, do either of the -// following things in any header used by `include!` in the bridge. -// -// --- if you define the type: -// struct MyType { -// ... -// + using IsRelocatable = std::true_type; -// }; -// -// --- otherwise: -// + template <> -// + struct rust::IsRelocatable : std::true_type {}; + // IsRelocatable is used in assertions that a C++ type passed by value + // between Rust and C++ is soundly relocatable by Rust. + // + // There may be legitimate reasons to opt out of the check for support of types + // that the programmer knows are soundly Rust-movable despite not being + // recognized as such by the C++ type system due to a move constructor or + // destructor. To opt out of the relocatability check, do either of the + // following things in any header used by `include!` in the bridge. + // + // --- if you define the type: + // struct MyType { + // ... + // + using IsRelocatable = std::true_type; + // }; + // + // --- otherwise: + // + template <> + // + struct rust::IsRelocatable : std::true_type {}; template struct IsRelocatable; @@ -458,7 +456,7 @@ namespace rust { using u16 = std::uint16_t; using u32 = std::uint32_t; using u64 = std::uint64_t; - using usize = std::size_t; // see static asserts in cxx.cc + using usize = std::size_t; // see static asserts in cxx.cc using i8 = std::int8_t; using i16 = std::int16_t; using i32 = std::int32_t; @@ -466,7 +464,7 @@ namespace rust { using f32 = float; using f64 = double; -// Snake case aliases for use in code that uses this style for type names. + // Snake case aliases for use in code that uses this style for type names. using string = String; using str = Str; template @@ -481,635 +479,620 @@ namespace rust { template using is_relocatable = IsRelocatable; - - -//////////////////////////////////////////////////////////////////////////////// -/// end public API, begin implementation details + //////////////////////////////////////////////////////////////////////////////// + /// end public API, begin implementation details #ifndef CXXBRIDGE1_PANIC #define CXXBRIDGE1_PANIC template void panic [[noreturn]] (const char *msg); -#endif // CXXBRIDGE1_PANIC +#endif // CXXBRIDGE1_PANIC #ifndef CXXBRIDGE1_RUST_FN #define CXXBRIDGE1_RUST_FN template Ret Fn::operator()(Args... args) const noexcept { - return (*this->trampoline)(std::forward(args)..., this->fn); - } + return (*this->trampoline)(std::forward(args)..., this->fn); + } - template - Fn Fn::operator*() const noexcept { - return *this; -} -#endif // CXXBRIDGE1_RUST_FN + template + Fn Fn::operator*() const noexcept { + return *this; + } +#endif // CXXBRIDGE1_RUST_FN #ifndef CXXBRIDGE1_RUST_BITCOPY_T #define CXXBRIDGE1_RUST_BITCOPY_T -struct unsafe_bitcopy_t final { - explicit unsafe_bitcopy_t() = default; -}; -#endif // CXXBRIDGE1_RUST_BITCOPY_T + struct unsafe_bitcopy_t final { + explicit unsafe_bitcopy_t() = default; + }; +#endif // CXXBRIDGE1_RUST_BITCOPY_T #ifndef CXXBRIDGE1_RUST_BITCOPY #define CXXBRIDGE1_RUST_BITCOPY -constexpr unsafe_bitcopy_t unsafe_bitcopy{}; -#endif // CXXBRIDGE1_RUST_BITCOPY + constexpr unsafe_bitcopy_t unsafe_bitcopy{}; +#endif // CXXBRIDGE1_RUST_BITCOPY #ifndef CXXBRIDGE1_RUST_SLICE #define CXXBRIDGE1_RUST_SLICE -template -Slice::Slice() noexcept { -sliceInit(this, reinterpret_cast(align_of()), 0); -} - -template -Slice::Slice(T *s, std::size_t count) noexcept { -assert(s != nullptr || count == 0); -sliceInit(this, -s == nullptr && count == 0 -? reinterpret_cast(align_of()) -: const_cast::type *>(s), - count); -} - -template -T *Slice::data() const noexcept { -return reinterpret_cast(slicePtr(this)); -} - -template -std::size_t Slice::size() const noexcept { -return sliceLen(this); -} - -template -std::size_t Slice::length() const noexcept { -return this->size(); -} - -template -bool Slice::empty() const noexcept { -return this->size() == 0; -} - -template -T &Slice::operator[](std::size_t n) const noexcept { -assert(n < this->size()); -auto ptr = static_cast(slicePtr(this)) + size_of() * n; -return *reinterpret_cast(ptr); -} - -template -T &Slice::at(std::size_t n) const { - if (n >= this->size()) { - panic("rust::Slice index out of range"); - } - return (*this)[n]; -} - -template -T &Slice::front() const noexcept { -assert(!this->empty()); -return (*this)[0]; -} - -template -T &Slice::back() const noexcept { -assert(!this->empty()); -return (*this)[this->size() - 1]; -} - -template -typename Slice::iterator::reference -Slice::iterator::operator*() const noexcept { -return *static_cast(this->pos); -} - -template -typename Slice::iterator::pointer -Slice::iterator::operator->() const noexcept { -return static_cast(this->pos); -} - -template -typename Slice::iterator::reference Slice::iterator::operator[]( - typename Slice::iterator::difference_type n) const noexcept { -auto ptr = static_cast(this->pos) + this->stride * n; -return *reinterpret_cast(ptr); -} - -template -typename Slice::iterator &Slice::iterator::operator++() noexcept { -this->pos = static_cast(this->pos) + this->stride; -return *this; -} - -template -typename Slice::iterator Slice::iterator::operator++(int) noexcept { -auto ret = iterator(*this); -this->pos = static_cast(this->pos) + this->stride; -return ret; -} - -template -typename Slice::iterator &Slice::iterator::operator--() noexcept { -this->pos = static_cast(this->pos) - this->stride; -return *this; -} - -template -typename Slice::iterator Slice::iterator::operator--(int) noexcept { -auto ret = iterator(*this); -this->pos = static_cast(this->pos) - this->stride; -return ret; -} - -template -typename Slice::iterator &Slice::iterator::operator+=( - typename Slice::iterator::difference_type n) noexcept { -this->pos = static_cast(this->pos) + this->stride * n; -return *this; -} - -template -typename Slice::iterator &Slice::iterator::operator-=( - typename Slice::iterator::difference_type n) noexcept { -this->pos = static_cast(this->pos) - this->stride * n; -return *this; -} - -template -typename Slice::iterator Slice::iterator::operator+( - typename Slice::iterator::difference_type n) const noexcept { -auto ret = iterator(*this); -ret.pos = static_cast(this->pos) + this->stride * n; -return ret; -} - -template -typename Slice::iterator Slice::iterator::operator-( - typename Slice::iterator::difference_type n) const noexcept { -auto ret = iterator(*this); -ret.pos = static_cast(this->pos) - this->stride * n; -return ret; -} - -template -typename Slice::iterator::difference_type -Slice::iterator::operator-(const iterator &other) const noexcept { -auto diff = std::distance(static_cast(other.pos), - static_cast(this->pos)); -return diff / this->stride; -} - -template -bool Slice::iterator::operator==(const iterator &other) const noexcept { -return this->pos == other.pos; -} - -template -bool Slice::iterator::operator!=(const iterator &other) const noexcept { -return this->pos != other.pos; -} - -template -bool Slice::iterator::operator<(const iterator &other) const noexcept { -return this->pos < other.pos; -} - -template -bool Slice::iterator::operator<=(const iterator &other) const noexcept { -return this->pos <= other.pos; -} - -template -bool Slice::iterator::operator>(const iterator &other) const noexcept { -return this->pos > other.pos; -} - -template -bool Slice::iterator::operator>=(const iterator &other) const noexcept { -return this->pos >= other.pos; -} - -template -typename Slice::iterator Slice::begin() const noexcept { -iterator it; -it.pos = slicePtr(this); -it.stride = size_of(); -return it; -} - -template -typename Slice::iterator Slice::end() const noexcept { -iterator it = this->begin(); -it.pos = static_cast(it.pos) + it.stride * this->size(); -return it; -} - -template -void Slice::swap(Slice &rhs) noexcept { -std::swap(*this, rhs); -} -#endif // CXXBRIDGE1_RUST_SLICE + template + Slice::Slice() noexcept { + sliceInit(this, reinterpret_cast(align_of()), 0); + } + + template + Slice::Slice(T *s, std::size_t count) noexcept { + assert(s != nullptr || count == 0); + sliceInit(this, + s == nullptr && count == 0 ? reinterpret_cast(align_of()) + : const_cast::type *>(s), + count); + } + + template + T *Slice::data() const noexcept { + return reinterpret_cast(slicePtr(this)); + } + + template + std::size_t Slice::size() const noexcept { + return sliceLen(this); + } + + template + std::size_t Slice::length() const noexcept { + return this->size(); + } + + template + bool Slice::empty() const noexcept { + return this->size() == 0; + } + + template + T &Slice::operator[](std::size_t n) const noexcept { + assert(n < this->size()); + auto ptr = static_cast(slicePtr(this)) + size_of() * n; + return *reinterpret_cast(ptr); + } + + template + T &Slice::at(std::size_t n) const { + if (n >= this->size()) { + panic("rust::Slice index out of range"); + } + return (*this)[n]; + } + + template + T &Slice::front() const noexcept { + assert(!this->empty()); + return (*this)[0]; + } + + template + T &Slice::back() const noexcept { + assert(!this->empty()); + return (*this)[this->size() - 1]; + } + + template + typename Slice::iterator::reference Slice::iterator::operator*() const noexcept { + return *static_cast(this->pos); + } + + template + typename Slice::iterator::pointer Slice::iterator::operator->() const noexcept { + return static_cast(this->pos); + } + + template + typename Slice::iterator::reference Slice::iterator::operator[]( + typename Slice::iterator::difference_type n) const noexcept { + auto ptr = static_cast(this->pos) + this->stride * n; + return *reinterpret_cast(ptr); + } + + template + typename Slice::iterator &Slice::iterator::operator++() noexcept { + this->pos = static_cast(this->pos) + this->stride; + return *this; + } + + template + typename Slice::iterator Slice::iterator::operator++(int) noexcept { + auto ret = iterator(*this); + this->pos = static_cast(this->pos) + this->stride; + return ret; + } + + template + typename Slice::iterator &Slice::iterator::operator--() noexcept { + this->pos = static_cast(this->pos) - this->stride; + return *this; + } + + template + typename Slice::iterator Slice::iterator::operator--(int) noexcept { + auto ret = iterator(*this); + this->pos = static_cast(this->pos) - this->stride; + return ret; + } + + template + typename Slice::iterator &Slice::iterator::operator+=( + typename Slice::iterator::difference_type n) noexcept { + this->pos = static_cast(this->pos) + this->stride * n; + return *this; + } + + template + typename Slice::iterator &Slice::iterator::operator-=( + typename Slice::iterator::difference_type n) noexcept { + this->pos = static_cast(this->pos) - this->stride * n; + return *this; + } + + template + typename Slice::iterator Slice::iterator::operator+( + typename Slice::iterator::difference_type n) const noexcept { + auto ret = iterator(*this); + ret.pos = static_cast(this->pos) + this->stride * n; + return ret; + } + + template + typename Slice::iterator Slice::iterator::operator-( + typename Slice::iterator::difference_type n) const noexcept { + auto ret = iterator(*this); + ret.pos = static_cast(this->pos) - this->stride * n; + return ret; + } + + template + typename Slice::iterator::difference_type Slice::iterator::operator-( + const iterator &other) const noexcept { + auto diff = std::distance(static_cast(other.pos), static_cast(this->pos)); + return diff / static_cast::iterator::difference_type>(this->stride); + } + + template + bool Slice::iterator::operator==(const iterator &other) const noexcept { + return this->pos == other.pos; + } + + template + bool Slice::iterator::operator!=(const iterator &other) const noexcept { + return this->pos != other.pos; + } + + template + bool Slice::iterator::operator<(const iterator &other) const noexcept { + return this->pos < other.pos; + } + + template + bool Slice::iterator::operator<=(const iterator &other) const noexcept { + return this->pos <= other.pos; + } + + template + bool Slice::iterator::operator>(const iterator &other) const noexcept { + return this->pos > other.pos; + } + + template + bool Slice::iterator::operator>=(const iterator &other) const noexcept { + return this->pos >= other.pos; + } + + template + typename Slice::iterator Slice::begin() const noexcept { + iterator it; + it.pos = slicePtr(this); + it.stride = size_of(); + return it; + } + + template + typename Slice::iterator Slice::end() const noexcept { + iterator it = this->begin(); + it.pos = static_cast(it.pos) + it.stride * this->size(); + return it; + } + + template + void Slice::swap(Slice &rhs) noexcept { + std::swap(*this, rhs); + } +#endif // CXXBRIDGE1_RUST_SLICE #ifndef CXXBRIDGE1_RUST_BOX #define CXXBRIDGE1_RUST_BOX -template -class Box::uninit {}; - -template -class Box::allocation { - static T *alloc() noexcept; - static void dealloc(T *) noexcept; - -public: - allocation() noexcept : ptr(alloc()) {} - ~allocation() noexcept { - if (this->ptr) { - dealloc(this->ptr); - } - } - T *ptr; -}; - -template -Box::Box(Box &&other) noexcept : ptr(other.ptr) { -other.ptr = nullptr; -} - -template -Box::Box(const T &val) { - allocation alloc; - ::new (alloc.ptr) T(val); - this->ptr = alloc.ptr; - alloc.ptr = nullptr; -} - -template -Box::Box(T &&val) { - allocation alloc; - ::new (alloc.ptr) T(std::move(val)); - this->ptr = alloc.ptr; - alloc.ptr = nullptr; -} - -template -Box::~Box() noexcept { -if (this->ptr) { -this->drop(); -} -} - -template -Box &Box::operator=(Box &&other) &noexcept { -if (this->ptr) { -this->drop(); -} -this->ptr = other.ptr; -other.ptr = nullptr; -return *this; -} - -template -const T *Box::operator->() const noexcept { -return this->ptr; -} - -template -const T &Box::operator*() const noexcept { -return *this->ptr; -} - -template -T *Box::operator->() noexcept { -return this->ptr; -} - -template -T &Box::operator*() noexcept { -return *this->ptr; -} - -template -template -Box Box::in_place(Fields &&...fields) { - allocation alloc; - auto ptr = alloc.ptr; - ::new (ptr) T{std::forward(fields)...}; - alloc.ptr = nullptr; - return from_raw(ptr); -} - -template -void Box::swap(Box &rhs) noexcept { -using std::swap; -swap(this->ptr, rhs.ptr); -} - -template -Box Box::from_raw(T *raw) noexcept { -Box box = uninit{}; -box.ptr = raw; -return box; -} - -template -T *Box::into_raw() noexcept { -T *raw = this->ptr; -this->ptr = nullptr; -return raw; -} - -template -Box::Box(uninit) noexcept {} -#endif // CXXBRIDGE1_RUST_BOX + template + class Box::uninit {}; + + template + class Box::allocation { + static T *alloc() noexcept; + static void dealloc(T *) noexcept; + + public: + allocation() noexcept + : ptr(alloc()) {} + ~allocation() noexcept { + if (this->ptr) { + dealloc(this->ptr); + } + } + T *ptr; + }; + + template + Box::Box(Box &&other) noexcept + : ptr(other.ptr) { + other.ptr = nullptr; + } + + template + Box::Box(const T &val) { + allocation alloc; + ::new (alloc.ptr) T(val); + this->ptr = alloc.ptr; + alloc.ptr = nullptr; + } + + template + Box::Box(T &&val) { + allocation alloc; + ::new (alloc.ptr) T(std::move(val)); + this->ptr = alloc.ptr; + alloc.ptr = nullptr; + } + + template + Box::~Box() noexcept { + if (this->ptr) { + this->drop(); + } + } + + template + Box &Box::operator=(Box &&other) &noexcept { + if (this->ptr) { + this->drop(); + } + this->ptr = other.ptr; + other.ptr = nullptr; + return *this; + } + + template + const T *Box::operator->() const noexcept { + return this->ptr; + } + + template + const T &Box::operator*() const noexcept { + return *this->ptr; + } + + template + T *Box::operator->() noexcept { + return this->ptr; + } + + template + T &Box::operator*() noexcept { + return *this->ptr; + } + + template + template + Box Box::in_place(Fields &&...fields) { + allocation alloc; + auto ptr = alloc.ptr; + ::new (ptr) T{std::forward(fields)...}; + alloc.ptr = nullptr; + return from_raw(ptr); + } + + template + void Box::swap(Box &rhs) noexcept { + using std::swap; + swap(this->ptr, rhs.ptr); + } + + template + Box Box::from_raw(T *raw) noexcept { + Box box = uninit{}; + box.ptr = raw; + return box; + } + + template + T *Box::into_raw() noexcept { + T *raw = this->ptr; + this->ptr = nullptr; + return raw; + } + + template + Box::Box(uninit) noexcept {} +#endif // CXXBRIDGE1_RUST_BOX #ifndef CXXBRIDGE1_RUST_VEC #define CXXBRIDGE1_RUST_VEC -template -Vec::Vec(std::initializer_list init) : Vec{} { - this->reserve_total(init.size()); - std::move(init.begin(), init.end(), std::back_inserter(*this)); -} - -template -Vec::Vec(const Vec &other) : Vec() { - this->reserve_total(other.size()); - std::copy(other.begin(), other.end(), std::back_inserter(*this)); -} - -template -Vec::Vec(Vec &&other) noexcept : repr(other.repr) { -new (&other) Vec(); -} - -template -Vec::~Vec() noexcept { -this->drop(); -} - -template -Vec &Vec::operator=(Vec &&other) &noexcept { -this->drop(); -this->repr = other.repr; -new (&other) Vec(); -return *this; -} - -template -Vec &Vec::operator=(const Vec &other) & { - if (this != &other) { - this->drop(); - new (this) Vec(other); - } - return *this; -} - -template -bool Vec::empty() const noexcept { -return this->size() == 0; -} - -template -T *Vec::data() noexcept { -return const_cast(const_cast *>(this)->data()); -} - -template -const T &Vec::operator[](std::size_t n) const noexcept { -assert(n < this->size()); -auto data = reinterpret_cast(this->data()); -return *reinterpret_cast(data + n * size_of()); -} - -template -const T &Vec::at(std::size_t n) const { - if (n >= this->size()) { - panic("rust::Vec index out of range"); - } - return (*this)[n]; -} - -template -const T &Vec::front() const noexcept { -assert(!this->empty()); -return (*this)[0]; -} - -template -const T &Vec::back() const noexcept { -assert(!this->empty()); -return (*this)[this->size() - 1]; -} - -template -T &Vec::operator[](std::size_t n) noexcept { -assert(n < this->size()); -auto data = reinterpret_cast(this->data()); -return *reinterpret_cast(data + n * size_of()); -} - -template -T &Vec::at(std::size_t n) { - if (n >= this->size()) { - panic("rust::Vec index out of range"); - } - return (*this)[n]; -} - -template -T &Vec::front() noexcept { -assert(!this->empty()); -return (*this)[0]; -} - -template -T &Vec::back() noexcept { -assert(!this->empty()); -return (*this)[this->size() - 1]; -} - -template -void Vec::reserve(std::size_t new_cap) { - this->reserve_total(new_cap); -} - -template -void Vec::push_back(const T &value) { - this->emplace_back(value); -} - -template -void Vec::push_back(T &&value) { - this->emplace_back(std::move(value)); -} - -template -template -void Vec::emplace_back(Args &&...args) { - auto size = this->size(); - this->reserve_total(size + 1); - ::new (reinterpret_cast(reinterpret_cast(this->data()) + - size * size_of())) - T(std::forward(args)...); - this->set_len(size + 1); -} - -template -void Vec::clear() { - this->truncate(0); -} - -template -typename Vec::iterator Vec::begin() noexcept { -return Slice(this->data(), this->size()).begin(); -} - -template -typename Vec::iterator Vec::end() noexcept { -return Slice(this->data(), this->size()).end(); -} - -template -typename Vec::const_iterator Vec::begin() const noexcept { -return this->cbegin(); -} - -template -typename Vec::const_iterator Vec::end() const noexcept { -return this->cend(); -} - -template -typename Vec::const_iterator Vec::cbegin() const noexcept { -return Slice(this->data(), this->size()).begin(); -} - -template -typename Vec::const_iterator Vec::cend() const noexcept { -return Slice(this->data(), this->size()).end(); -} - -template -void Vec::swap(Vec &rhs) noexcept { -using std::swap; -swap(this->repr, rhs.repr); -} - -// Internal API only intended for the cxxbridge code generator. -template -Vec::Vec(unsafe_bitcopy_t, const Vec &bits) noexcept : repr(bits.repr) {} -#endif // CXXBRIDGE1_RUST_VEC + template + Vec::Vec(std::initializer_list init) + : Vec{} { + this->reserve_total(init.size()); + std::move(init.begin(), init.end(), std::back_inserter(*this)); + } + + template + Vec::Vec(const Vec &other) + : Vec() { + this->reserve_total(other.size()); + std::copy(other.begin(), other.end(), std::back_inserter(*this)); + } + + template + Vec::Vec(Vec &&other) noexcept + : repr(other.repr) { + new (&other) Vec(); + } + + template + Vec::~Vec() noexcept { + this->drop(); + } + + template + Vec &Vec::operator=(Vec &&other) &noexcept { + this->drop(); + this->repr = other.repr; + new (&other) Vec(); + return *this; + } + + template + Vec &Vec::operator=(const Vec &other) & { + if (this != &other) { + this->drop(); + new (this) Vec(other); + } + return *this; + } + + template + bool Vec::empty() const noexcept { + return this->size() == 0; + } + + template + T *Vec::data() noexcept { + return const_cast(const_cast *>(this)->data()); + } + + template + const T &Vec::operator[](std::size_t n) const noexcept { + assert(n < this->size()); + auto data = reinterpret_cast(this->data()); + return *reinterpret_cast(data + n * size_of()); + } + + template + const T &Vec::at(std::size_t n) const { + if (n >= this->size()) { + panic("rust::Vec index out of range"); + } + return (*this)[n]; + } + + template + const T &Vec::front() const noexcept { + assert(!this->empty()); + return (*this)[0]; + } + + template + const T &Vec::back() const noexcept { + assert(!this->empty()); + return (*this)[this->size() - 1]; + } + + template + T &Vec::operator[](std::size_t n) noexcept { + assert(n < this->size()); + auto data = reinterpret_cast(this->data()); + return *reinterpret_cast(data + n * size_of()); + } + + template + T &Vec::at(std::size_t n) { + if (n >= this->size()) { + panic("rust::Vec index out of range"); + } + return (*this)[n]; + } + + template + T &Vec::front() noexcept { + assert(!this->empty()); + return (*this)[0]; + } + + template + T &Vec::back() noexcept { + assert(!this->empty()); + return (*this)[this->size() - 1]; + } + + template + void Vec::reserve(std::size_t new_cap) { + this->reserve_total(new_cap); + } + + template + void Vec::push_back(const T &value) { + this->emplace_back(value); + } + + template + void Vec::push_back(T &&value) { + this->emplace_back(std::move(value)); + } + + template + template + void Vec::emplace_back(Args &&...args) { + auto size = this->size(); + this->reserve_total(size + 1); + ::new (reinterpret_cast(reinterpret_cast(this->data()) + size * size_of())) + T(std::forward(args)...); + this->set_len(size + 1); + } + + template + void Vec::clear() { + this->truncate(0); + } + + template + typename Vec::iterator Vec::begin() noexcept { + return Slice(this->data(), this->size()).begin(); + } + + template + typename Vec::iterator Vec::end() noexcept { + return Slice(this->data(), this->size()).end(); + } + + template + typename Vec::const_iterator Vec::begin() const noexcept { + return this->cbegin(); + } + + template + typename Vec::const_iterator Vec::end() const noexcept { + return this->cend(); + } + + template + typename Vec::const_iterator Vec::cbegin() const noexcept { + return Slice(this->data(), this->size()).begin(); + } + + template + typename Vec::const_iterator Vec::cend() const noexcept { + return Slice(this->data(), this->size()).end(); + } + + template + void Vec::swap(Vec &rhs) noexcept { + using std::swap; + swap(this->repr, rhs.repr); + } + + // Internal API only intended for the cxxbridge code generator. + template + Vec::Vec(unsafe_bitcopy_t, const Vec &bits) noexcept + : repr(bits.repr) {} +#endif // CXXBRIDGE1_RUST_VEC #ifndef CXXBRIDGE1_IS_COMPLETE #define CXXBRIDGE1_IS_COMPLETE -namespace detail { - namespace { - template - struct is_complete : std::false_type {}; - template - struct is_complete : std::true_type {}; - } // namespace -} // namespace detail -#endif // CXXBRIDGE1_IS_COMPLETE + namespace detail { + namespace { + template + struct is_complete : std::false_type {}; + template + struct is_complete : std::true_type {}; + } // namespace + } // namespace detail +#endif // CXXBRIDGE1_IS_COMPLETE #ifndef CXXBRIDGE1_LAYOUT #define CXXBRIDGE1_LAYOUT -class layout { - template - friend std::size_t size_of(); - template - friend std::size_t align_of(); - template - static typename std::enable_if::value, - std::size_t>::type - do_size_of() { - return T::layout::size(); - } - template - static typename std::enable_if::value, - std::size_t>::type - do_size_of() { - return sizeof(T); - } - template - static - typename std::enable_if::value, std::size_t>::type - size_of() { - return do_size_of(); - } - template - static typename std::enable_if::value, - std::size_t>::type - do_align_of() { - return T::layout::align(); - } - template - static typename std::enable_if::value, - std::size_t>::type - do_align_of() { - return alignof(T); - } - template - static - typename std::enable_if::value, std::size_t>::type - align_of() { - return do_align_of(); - } -}; - -template -std::size_t size_of() { - return layout::size_of(); -} - -template -std::size_t align_of() { - return layout::align_of(); -} -#endif // CXXBRIDGE1_LAYOUT + class layout { + template + friend std::size_t size_of(); + template + friend std::size_t align_of(); + template + static typename std::enable_if::value, std::size_t>::type do_size_of() { + return T::layout::size(); + } + template + static typename std::enable_if::value, std::size_t>::type do_size_of() { + return sizeof(T); + } + template + static typename std::enable_if::value, std::size_t>::type size_of() { + return do_size_of(); + } + template + static typename std::enable_if::value, std::size_t>::type do_align_of() { + return T::layout::align(); + } + template + static typename std::enable_if::value, std::size_t>::type do_align_of() { + return alignof(T); + } + template + static typename std::enable_if::value, std::size_t>::type align_of() { + return do_align_of(); + } + }; + + template + std::size_t size_of() { + return layout::size_of(); + } + + template + std::size_t align_of() { + return layout::align_of(); + } +#endif // CXXBRIDGE1_LAYOUT #ifndef CXXBRIDGE1_RELOCATABLE #define CXXBRIDGE1_RELOCATABLE -namespace detail { - template - struct make_void { - using type = void; - }; - - template - using void_t = typename make_void::type; - - template class, typename...> - struct detect : std::false_type {}; - template