Compare commits
No commits in common. "a81271c0a8a2b07cb6f2291ff7af8d1e8d399ecf" and "e71d618d10c7097c99b243de9540c050ec461eec" have entirely different histories.
a81271c0a8
...
e71d618d10
@ -1,2 +1,3 @@
|
||||
[build]
|
||||
rustflags = ["--cfg", "tokio_unstable"]
|
||||
rustdocflags = ["--cfg", "tokio_unstable"]
|
||||
|
572
Cargo.lock
generated
572
Cargo.lock
generated
@ -255,32 +255,6 @@ name = "camino"
|
||||
version = "1.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0da45bc31171d8d6960122e222a67740df867c1dd53b4d51caa297084c185cab"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cargo-platform"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cargo_metadata"
|
||||
version = "0.19.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd5eb614ed4c27c5d706420e4320fbe3216ab31fa1c33cd8246ac36dae4479ba"
|
||||
dependencies = [
|
||||
"camino",
|
||||
"cargo-platform",
|
||||
"semver",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
@ -288,8 +262,6 @@ version = "1.2.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d487aa071b5f64da6f19a3e848e3578944b726ee5a4854b82172f02aa876bfdc"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
"libc",
|
||||
"shlex",
|
||||
]
|
||||
|
||||
@ -472,46 +444,6 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "deranged"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e"
|
||||
dependencies = [
|
||||
"powerfmt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_builder"
|
||||
version = "0.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947"
|
||||
dependencies = [
|
||||
"derive_builder_macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_builder_core"
|
||||
version = "0.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8"
|
||||
dependencies = [
|
||||
"darling",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_builder_macro"
|
||||
version = "0.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c"
|
||||
dependencies = [
|
||||
"derive_builder_core",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_more"
|
||||
version = "2.0.1"
|
||||
@ -534,17 +466,6 @@ dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "displaydoc"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.15.0"
|
||||
@ -589,15 +510,6 @@ version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||
|
||||
[[package]]
|
||||
name = "form_urlencoded"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456"
|
||||
dependencies = [
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.31"
|
||||
@ -645,19 +557,7 @@ checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi 0.11.1+wasi-snapshot-preview1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"r-efi",
|
||||
"wasi 0.14.2+wasi-0.2.4",
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -666,19 +566,6 @@ version = "0.31.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
|
||||
|
||||
[[package]]
|
||||
name = "git2"
|
||||
version = "0.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2deb07a133b1520dc1a5690e9bd08950108873d7ed5de38dcc74d3b5ebffa110"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"libc",
|
||||
"libgit2-sys",
|
||||
"log",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.2"
|
||||
@ -842,119 +729,12 @@ dependencies = [
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "icu_collections"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "200072f5d0e3614556f94a9930d5dc3e0662a652823904c3a75dc3b0af7fee47"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"potential_utf",
|
||||
"yoke",
|
||||
"zerofrom",
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "icu_locale_core"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0cde2700ccaed3872079a65fb1a78f6c0a36c91570f28755dda67bc8f7d9f00a"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"litemap",
|
||||
"tinystr",
|
||||
"writeable",
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "icu_normalizer"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "436880e8e18df4d7bbc06d58432329d6458cc84531f7ac5f024e93deadb37979"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"icu_collections",
|
||||
"icu_normalizer_data",
|
||||
"icu_properties",
|
||||
"icu_provider",
|
||||
"smallvec",
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "icu_normalizer_data"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00210d6893afc98edb752b664b8890f0ef174c8adbb8d0be9710fa66fbbf72d3"
|
||||
|
||||
[[package]]
|
||||
name = "icu_properties"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "016c619c1eeb94efb86809b015c58f479963de65bdb6253345c1a1276f22e32b"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"icu_collections",
|
||||
"icu_locale_core",
|
||||
"icu_properties_data",
|
||||
"icu_provider",
|
||||
"potential_utf",
|
||||
"zerotrie",
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "icu_properties_data"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "298459143998310acd25ffe6810ed544932242d3f07083eee1084d83a71bd632"
|
||||
|
||||
[[package]]
|
||||
name = "icu_provider"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03c80da27b5f4187909049ee2d72f276f0d9f99a42c306bd0131ecfe04d8e5af"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"icu_locale_core",
|
||||
"stable_deref_trait",
|
||||
"tinystr",
|
||||
"writeable",
|
||||
"yoke",
|
||||
"zerofrom",
|
||||
"zerotrie",
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ident_case"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e"
|
||||
dependencies = [
|
||||
"idna_adapter",
|
||||
"smallvec",
|
||||
"utf8_iter",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "idna_adapter"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344"
|
||||
dependencies = [
|
||||
"icu_normalizer",
|
||||
"icu_properties",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.9.3"
|
||||
@ -1005,16 +785,6 @@ version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
||||
|
||||
[[package]]
|
||||
name = "jobserver"
|
||||
version = "0.1.33"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a"
|
||||
dependencies = [
|
||||
"getrandom 0.3.3",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.5.0"
|
||||
@ -1023,7 +793,7 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||
|
||||
[[package]]
|
||||
name = "lb"
|
||||
version = "0.0.1"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"camino",
|
||||
"derive_more",
|
||||
@ -1032,7 +802,6 @@ dependencies = [
|
||||
"luajit",
|
||||
"sysexits",
|
||||
"tokio",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1041,18 +810,6 @@ version = "0.2.174"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776"
|
||||
|
||||
[[package]]
|
||||
name = "libgit2-sys"
|
||||
version = "0.18.2+1.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1c42fe03df2bd3c53a3a9c7317ad91d80c81cd1fb0caec8d7cc4cd2bfa10c222"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"libz-sys",
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
version = "0.8.8"
|
||||
@ -1073,30 +830,12 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libz-sys"
|
||||
version = "1.1.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b70e7a7df205e92a1a4cd9aaae7898dac0aa555503cc0a649494d0d60e7651d"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"pkg-config",
|
||||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12"
|
||||
|
||||
[[package]]
|
||||
name = "litemap"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.13"
|
||||
@ -1115,7 +854,7 @@ checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
|
||||
|
||||
[[package]]
|
||||
name = "luaffi"
|
||||
version = "0.0.1"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bstr",
|
||||
"luaffi_impl",
|
||||
@ -1126,7 +865,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "luaffi_impl"
|
||||
version = "0.0.1"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"darling",
|
||||
"proc-macro2",
|
||||
@ -1136,7 +875,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "luaify"
|
||||
version = "0.0.1"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -1145,7 +884,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "luajit"
|
||||
version = "0.0.1"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bstr",
|
||||
@ -1156,7 +895,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "luajit-sys"
|
||||
version = "0.0.1"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"cc",
|
||||
@ -1165,7 +904,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "luby"
|
||||
version = "0.0.1"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"console-subscriber",
|
||||
@ -1177,7 +916,6 @@ dependencies = [
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"vergen-git2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1238,7 +976,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"wasi 0.11.1+wasi-snapshot-preview1",
|
||||
"wasi",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
@ -1262,12 +1000,6 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-conv"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
@ -1277,15 +1009,6 @@ dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_threads"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.36.7"
|
||||
@ -1315,9 +1038,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
|
||||
|
||||
[[package]]
|
||||
name = "owo-colors"
|
||||
version = "4.2.2"
|
||||
version = "4.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "48dd4f4a2c8405440fd0462561f0e5806bd0f77e86f51c761481bdd4018b545e"
|
||||
checksum = "26995317201fa17f3656c36716aed4a7c81743a9634ac4c99c0eeda495db0cec"
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
@ -1380,27 +1103,6 @@ version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
|
||||
|
||||
[[package]]
|
||||
name = "potential_utf"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5a7c30837279ca13e7c867e9e40053bc68740f988cb07f7ca6df43cc734b585"
|
||||
dependencies = [
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "powerfmt"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.21"
|
||||
@ -1470,12 +1172,6 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "r-efi"
|
||||
version = "5.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.5"
|
||||
@ -1503,7 +1199,7 @@ version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||
dependencies = [
|
||||
"getrandom 0.2.16",
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1571,15 +1267,6 @@ version = "2.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
|
||||
dependencies = [
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "1.0.7"
|
||||
@ -1611,15 +1298,6 @@ version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.219"
|
||||
@ -1704,12 +1382,6 @@ dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stable_deref_trait"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.1"
|
||||
@ -1733,17 +1405,6 @@ version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263"
|
||||
|
||||
[[package]]
|
||||
name = "synstructure"
|
||||
version = "0.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sysexits"
|
||||
version = "0.9.0"
|
||||
@ -1779,49 +1440,6 @@ dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40"
|
||||
dependencies = [
|
||||
"deranged",
|
||||
"itoa",
|
||||
"libc",
|
||||
"num-conv",
|
||||
"num_threads",
|
||||
"powerfmt",
|
||||
"serde",
|
||||
"time-core",
|
||||
"time-macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time-core"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c"
|
||||
|
||||
[[package]]
|
||||
name = "time-macros"
|
||||
version = "0.2.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49"
|
||||
dependencies = [
|
||||
"num-conv",
|
||||
"time-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinystr"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d4f6d1145dcb577acf783d4e601bc1d76a13337bb54e6233add580b07344c8b"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.45.1"
|
||||
@ -2037,23 +1655,6 @@ version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
|
||||
|
||||
[[package]]
|
||||
name = "url"
|
||||
version = "2.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60"
|
||||
dependencies = [
|
||||
"form_urlencoded",
|
||||
"idna",
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "utf8_iter"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.2"
|
||||
@ -2066,53 +1667,6 @@ version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
||||
|
||||
[[package]]
|
||||
name = "vergen"
|
||||
version = "9.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6b2bf58be11fc9414104c6d3a2e464163db5ef74b12296bda593cac37b6e4777"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cargo_metadata",
|
||||
"derive_builder",
|
||||
"regex",
|
||||
"rustc_version",
|
||||
"rustversion",
|
||||
"vergen-lib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vergen-git2"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4f6ee511ec45098eabade8a0750e76eec671e7fb2d9360c563911336bea9cac1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"derive_builder",
|
||||
"git2",
|
||||
"rustversion",
|
||||
"time",
|
||||
"vergen",
|
||||
"vergen-lib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vergen-lib"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b07e6010c0f3e59fcb164e0163834597da68d1f864e2b8ca49f74de01e9c166"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"derive_builder",
|
||||
"rustversion",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "want"
|
||||
version = "0.3.1"
|
||||
@ -2128,15 +1682,6 @@ version = "0.11.1+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.14.2+wasi-0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3"
|
||||
dependencies = [
|
||||
"wit-bindgen-rt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "8.0.0"
|
||||
@ -2331,45 +1876,6 @@ version = "0.0.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904"
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-rt"
|
||||
version = "0.39.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "writeable"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb"
|
||||
|
||||
[[package]]
|
||||
name = "yoke"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5f41bb01b8226ef4bfd589436a297c53d118f65921786300e427be8d487695cc"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"stable_deref_trait",
|
||||
"yoke-derive",
|
||||
"zerofrom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "yoke-derive"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.8.26"
|
||||
@ -2389,57 +1895,3 @@ dependencies = [
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerofrom"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5"
|
||||
dependencies = [
|
||||
"zerofrom-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerofrom-derive"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerotrie"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36f0bbd478583f79edad978b407914f61b2972f5af6fa089686016be8f9af595"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"yoke",
|
||||
"zerofrom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerovec"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a05eb080e015ba39cc9e23bbe5e7fb04d5fb040350f99f34e338d5fdd294428"
|
||||
dependencies = [
|
||||
"yoke",
|
||||
"zerofrom",
|
||||
"zerovec-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerovec-derive"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
32
Cargo.toml
32
Cargo.toml
@ -1,5 +1,4 @@
|
||||
[workspace]
|
||||
resolver = "3"
|
||||
members = [
|
||||
"crates/lb",
|
||||
"crates/luaffi",
|
||||
@ -9,38 +8,23 @@ members = [
|
||||
"crates/luajit-sys",
|
||||
]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.0.1"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
authors = ["luaneko <lumi@lua.re>"]
|
||||
homepage = "https://git.lua.re/luaneko/luby/"
|
||||
repository = "https://git.lua.re/luaneko/luby/"
|
||||
|
||||
[package]
|
||||
name = "luby"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
[profile]
|
||||
dev.panic = "abort"
|
||||
release.panic = "abort"
|
||||
|
||||
[package]
|
||||
name = "luby"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.5.40", features = ["derive", "env"] }
|
||||
clap = { version = "4.5.40", features = ["derive"] }
|
||||
console-subscriber = "0.4.1"
|
||||
lb = { path = "crates/lb" }
|
||||
luajit = { path = "crates/luajit", features = ["runtime"] }
|
||||
lb = { version = "0.1.0", path = "crates/lb" }
|
||||
luajit = { version = "0.1.0", path = "crates/luajit", features = ["runtime"] }
|
||||
mimalloc = "0.1.47"
|
||||
owo-colors = "4.2.1"
|
||||
sysexits = "0.9.0"
|
||||
tokio = { version = "1.45.1", features = ["full", "tracing"] }
|
||||
tracing = "0.1.41"
|
||||
tracing-subscriber = "0.3.19"
|
||||
|
||||
[build-dependencies]
|
||||
vergen-git2 = { version = "1.0.7", features = ["cargo", "rustc"] }
|
||||
|
13
build.rs
13
build.rs
@ -1,13 +0,0 @@
|
||||
use vergen_git2::{CargoBuilder, Emitter, Git2Builder, RustcBuilder};
|
||||
|
||||
fn main() {
|
||||
Emitter::default()
|
||||
.add_instructions(&CargoBuilder::all_cargo().unwrap())
|
||||
.unwrap()
|
||||
.add_instructions(&Git2Builder::all_git().unwrap())
|
||||
.unwrap()
|
||||
.add_instructions(&RustcBuilder::all_rustc().unwrap())
|
||||
.unwrap()
|
||||
.emit()
|
||||
.unwrap();
|
||||
}
|
@ -1,20 +1,15 @@
|
||||
[package]
|
||||
name = "lb"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
camino = "1.1.10"
|
||||
derive_more = { version = "2.0.1", features = ["full"] }
|
||||
luaffi = { path = "../luaffi" }
|
||||
luajit = { path = "../luajit" }
|
||||
luaffi = { version = "0.1.0", path = "../luaffi" }
|
||||
luajit = { version = "0.1.0", path = "../luajit" }
|
||||
sysexits = "0.9.0"
|
||||
tokio = { version = "1.45.1", features = ["rt", "time", "fs", "net", "process", "signal", "tracing"] }
|
||||
tracing = "0.1.41"
|
||||
tokio = { version = "1.45.1", features = ["rt", "time", "fs", "net", "process", "signal"] }
|
||||
|
||||
[dev-dependencies]
|
||||
luaify = { path = "../luaify" }
|
||||
|
@ -1,7 +1,5 @@
|
||||
//! The `lb:fs` module provides utilities for interacting with the file system asynchronously.
|
||||
//!
|
||||
//! # Exports
|
||||
//!
|
||||
//! See [`lb_libfs`] for items exported by this module.
|
||||
use luaffi::{cdef, metatype};
|
||||
use std::io;
|
||||
@ -24,11 +22,11 @@ impl lb_libfs {
|
||||
Self
|
||||
}
|
||||
|
||||
pub async extern "Lua-C" fn read(&self, path: &str) -> io::Result<Vec<u8>> {
|
||||
fs::read(path).await
|
||||
pub extern "Lua" fn read(&self, path: string) -> string {
|
||||
self.__read(path)
|
||||
}
|
||||
|
||||
pub extern "Lua-C" fn read_sync(&self, path: &str) -> io::Result<Vec<u8>> {
|
||||
std::fs::read(path)
|
||||
async extern "Lua-C" fn __read(&self, path: &str) -> io::Result<Vec<u8>> {
|
||||
fs::read(path).await
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
//! The `lb:net` module provides an asynchronous network API for creating TCP or UDP servers and
|
||||
//! clients.
|
||||
//!
|
||||
//! # Exports
|
||||
//!
|
||||
//! See [`lb_libnet`] for items exported by this module.
|
||||
use derive_more::{From, FromStr};
|
||||
use luaffi::{cdef, metatype};
|
||||
@ -119,8 +117,8 @@ impl lb_libnet {
|
||||
/// # Errors
|
||||
///
|
||||
/// Throws if an error was encountered during the socket creation.
|
||||
pub extern "Lua-C" fn tcp_v4(&self) -> io::Result<lb_tcpsocket> {
|
||||
TcpSocket::new_v4().map(lb_tcpsocket)
|
||||
pub extern "Lua" fn tcp_v4(&self) -> lb_tcpsocket {
|
||||
self.__new_tcp_v4()
|
||||
}
|
||||
|
||||
/// Creates a new TCP socket configured for IPv6.
|
||||
@ -130,7 +128,15 @@ impl lb_libnet {
|
||||
/// # Errors
|
||||
///
|
||||
/// Throws if an error was encountered during the socket creation.
|
||||
pub extern "Lua-C" fn tcp_v6(&self) -> io::Result<lb_tcpsocket> {
|
||||
pub extern "Lua" fn tcp_v6(&self) -> lb_tcpsocket {
|
||||
self.__new_tcp_v6()
|
||||
}
|
||||
|
||||
extern "Lua-C" fn __new_tcp_v4(&self) -> io::Result<lb_tcpsocket> {
|
||||
TcpSocket::new_v4().map(lb_tcpsocket)
|
||||
}
|
||||
|
||||
extern "Lua-C" fn __new_tcp_v6(&self) -> io::Result<lb_tcpsocket> {
|
||||
TcpSocket::new_v6().map(lb_tcpsocket)
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,11 @@
|
||||
[package]
|
||||
name = "luaffi"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
bstr = "1.12.0"
|
||||
luaffi_impl = { path = "../luaffi_impl" }
|
||||
luaify = { path = "../luaify" }
|
||||
luaffi_impl = { version = "0.1.0", path = "../luaffi_impl" }
|
||||
luaify = { version = "0.1.0", path = "../luaify" }
|
||||
rustc-hash = "2.1.1"
|
||||
simdutf8 = "0.1.5"
|
||||
|
@ -177,15 +177,6 @@ unsafe impl<F: Future<Output: IntoFfi> + 'static> IntoFfi for lua_future<F> {
|
||||
self
|
||||
}
|
||||
|
||||
fn require_owned() -> bool {
|
||||
// future always requires full ownership of itself even if it's a "temporary", because we
|
||||
// must yield a full cdata to the runtime not a cdata containing a pointer to the future. if
|
||||
// this is set to false, postlude might receive a reference lua_future cdata instead of a
|
||||
// full lua_future cdata, and the runtime might incorrectly read the pointer value as
|
||||
// lua_future itself (it does not dereference it).
|
||||
true
|
||||
}
|
||||
|
||||
fn postlude(ret: &str) -> impl Display {
|
||||
// When returning a future from Rust to Lua, yield it immediately to the runtime which will
|
||||
// poll it to completion in the background, then take the fulfilled value once the thread
|
||||
|
@ -417,10 +417,6 @@ pub unsafe trait IntoFfi: Sized {
|
||||
}
|
||||
}
|
||||
|
||||
fn require_owned() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn postlude(_ret: &str) -> impl Display {
|
||||
""
|
||||
}
|
||||
@ -485,17 +481,12 @@ impl<'r, 'm> MetatypeMethodBuilder<'r, 'm> {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn param_str(
|
||||
&mut self,
|
||||
name: impl Display,
|
||||
allow_nil: bool,
|
||||
check_utf8: bool,
|
||||
) -> &mut Self {
|
||||
// fast-path for &[u8] and &str-like parameters
|
||||
pub fn param_str(&mut self, name: impl Display) -> &mut Self {
|
||||
// fast-path for &str and &[u8]-like parameters
|
||||
//
|
||||
// this passes one lua `string` argument as two C `const uint8_t *ptr` and `uintptr_t len`
|
||||
// arguments, bypassing the slower generic `&[u8]: FromFfi` path which constructs a
|
||||
// temporary cdata to pass the string and its length in one argument.
|
||||
// temporary cdata to pass the string and its length in one argument
|
||||
let Self {
|
||||
lparams,
|
||||
cparams,
|
||||
@ -504,26 +495,22 @@ impl<'r, 'm> MetatypeMethodBuilder<'r, 'm> {
|
||||
..
|
||||
} = self;
|
||||
|
||||
let param_ptr = <*const u8>::cdecl(&name);
|
||||
let param_len = usize::cdecl(format!("{name}_len"));
|
||||
let param_ptr = <*const u8>::cdecl("ptr");
|
||||
let param_len = usize::cdecl("len");
|
||||
|
||||
(!lparams.is_empty()).then(|| lparams.push_str(", "));
|
||||
(!cparams.is_empty()).then(|| cparams.push_str(", "));
|
||||
(!cargs.is_empty()).then(|| cargs.push_str(", "));
|
||||
|
||||
write!(lparams, "{name}").unwrap();
|
||||
write!(cparams, "{param_ptr}, {param_len}").unwrap();
|
||||
write!(cparams, "{param_ptr}, {param_len}",).unwrap();
|
||||
write!(cargs, "{name}, __{name}_len").unwrap();
|
||||
write!(prelude, "local __{name}_len = 0; if {name} ~= nil then ").unwrap();
|
||||
write!(prelude, r#"assert(type({name}) == "string", "string expected in argument '{name}', got " .. type({name})); "#).unwrap();
|
||||
write!(prelude, r#"__{name}_len = #{name}; "#).unwrap();
|
||||
if check_utf8 {
|
||||
write!(prelude, r#"assert(__C.{IS_UTF8_FN}({name}, __{name}_len), "argument '{name}' must be a valid utf-8 string"); "#).unwrap();
|
||||
}
|
||||
if !allow_nil {
|
||||
write!(prelude, r#"else return error("string expected in argument '{name}', got " .. type({name})); "#).unwrap();
|
||||
}
|
||||
write!(prelude, r#"end; "#).unwrap();
|
||||
write!(prelude, "local __{name}_len = 0; ").unwrap();
|
||||
write!(
|
||||
prelude,
|
||||
r#"if {name} ~= nil then assert(type({name}) == "string", "string expected in argument '{name}', got " .. type({name})); __{name}_len = #{name}; end; "#
|
||||
)
|
||||
.unwrap();
|
||||
self
|
||||
}
|
||||
|
||||
@ -558,21 +545,21 @@ impl<'r, 'm> MetatypeMethodBuilder<'r, 'm> {
|
||||
if T::Into::ty() == TypeType::Void {
|
||||
write!(lua, "__C.{func}({cargs}); {postlude}end").unwrap();
|
||||
} else {
|
||||
let check = T::postlude("__ret");
|
||||
write!(lua, "local __ret = __C.{func}({cargs}); ").unwrap();
|
||||
write!(lua, "{check}{postlude}return __ret; end").unwrap();
|
||||
let check = T::postlude("__res");
|
||||
write!(lua, "local __res = __C.{func}({cargs}); ").unwrap();
|
||||
write!(lua, "{check}{postlude}return __res; end").unwrap();
|
||||
}
|
||||
|
||||
writeln!(cdef, "{};", T::Into::cdecl(display!("{func}({cparams})"))).unwrap();
|
||||
}
|
||||
FfiReturnConvention::ByOutParam => {
|
||||
let ct = T::Into::name();
|
||||
let check = T::postlude("__out");
|
||||
write!(lua, "local __out = __new(__ct.{ct}); __C.{func}(__out").unwrap();
|
||||
let check = T::postlude("__res");
|
||||
write!(lua, "local __res = __new(__ct.{ct}); __C.{func}(__res").unwrap();
|
||||
if !cargs.is_empty() {
|
||||
write!(lua, ", {cargs}").unwrap();
|
||||
}
|
||||
write!(lua, "); {check}{postlude}return __out; end").unwrap();
|
||||
write!(lua, "); {check}{postlude}return __res; end").unwrap();
|
||||
write!(cdef, "void {func}({}", <*mut T::Into>::cdecl("out")).unwrap();
|
||||
if !cparams.is_empty() {
|
||||
write!(cdef, ", {cparams}").unwrap();
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
__internal::{disp, display},
|
||||
Cdef, CdefBuilder, IntoFfi, KEEP_FN, Type, TypeBuilder, TypeType,
|
||||
Cdef, CdefBuilder, IntoFfi, Type, TypeBuilder, TypeType,
|
||||
string::{DROP_BUFFER_FN, lua_buffer},
|
||||
};
|
||||
use std::{ffi::c_int, fmt::Display};
|
||||
@ -49,44 +49,22 @@ unsafe impl<T: IntoFfi, E: Display> IntoFfi for Result<T, E> {
|
||||
}
|
||||
}
|
||||
|
||||
fn require_owned() -> bool {
|
||||
// lua_result is only used to transmit information about whether an operation succeeded or
|
||||
// not and is forgotten immediately after use, so there is no need for an owned result
|
||||
false
|
||||
}
|
||||
|
||||
fn postlude(ret: &str) -> impl Display {
|
||||
disp(move |f| {
|
||||
let ct = T::Into::name();
|
||||
write!(f, "if {ret}.__tag ~= 0 then ")?;
|
||||
match T::Into::ty() {
|
||||
TypeType::Void => write!(f, "{ret} = nil; ")?, // for void results, we don't have a __value
|
||||
TypeType::Primitive => {
|
||||
// can always copy primitives to stack
|
||||
write!(f, "{ret} = {ret}.__value; {}", T::postlude(ret))?;
|
||||
}
|
||||
TypeType::Aggregate => {
|
||||
let ct = T::Into::name();
|
||||
if T::require_owned() {
|
||||
// inner value requires ownership; copy it into its own cdata and forget
|
||||
// result.
|
||||
write!(f, "{ret} = __new(__ct.{ct}, {ret}.__value); ")?;
|
||||
TypeType::Void => write!(f, "{ret} = nil; "), // for void results, we don't have a __value
|
||||
TypeType::Primitive => write!(f, "{ret} = {ret}.__value; "),
|
||||
TypeType::Aggregate => write!(f, "{ret} = __new(__ct.{ct}, {ret}.__value); "),
|
||||
}?;
|
||||
write!(f, "{}", T::postlude(ret))?;
|
||||
} else {
|
||||
// inner value is a "temporary" itself and doesn't require full ownership of
|
||||
// itself. we just need to keep the result object alive until its postlude
|
||||
// completes.
|
||||
write!(f, "local __{ret} = {ret}; {ret} = {ret}.__value; ")?;
|
||||
write!(f, "do {}end; ", T::postlude(ret))?;
|
||||
write!(f, "__C.{KEEP_FN}(__{ret}); ")?; // keep original result alive
|
||||
}
|
||||
}
|
||||
}
|
||||
write!(
|
||||
f,
|
||||
"else \
|
||||
local {ret}_err = __intern({ret}.__err.__ptr, {ret}.__err.__len); \
|
||||
local __{ret}_msg = __intern({ret}.__err.__ptr, {ret}.__err.__len); \
|
||||
__C.{DROP_BUFFER_FN}({ret}.__err); \
|
||||
return error({ret}_err); \
|
||||
return error(__{ret}_msg); \
|
||||
end; "
|
||||
)
|
||||
})
|
||||
|
@ -154,14 +154,8 @@ unsafe impl IntoFfi for &'static [u8] {
|
||||
lua_buf::new(self)
|
||||
}
|
||||
|
||||
fn require_owned() -> bool {
|
||||
// lua_buf is only used to have its contents interned then forgotten immediately; no need
|
||||
// for ownership of it
|
||||
false
|
||||
}
|
||||
|
||||
fn postlude(ret: &str) -> impl Display {
|
||||
display!("{ret} = __intern({ret}.__ptr, {ret}.__len); ")
|
||||
display!("{ret} = __intern({ret}.__ptr, {ret}.__len)")
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,15 +166,9 @@ unsafe impl IntoFfi for Vec<u8> {
|
||||
lua_buffer::new(self)
|
||||
}
|
||||
|
||||
fn require_owned() -> bool {
|
||||
// lua_buffer is only used to have its contents interned then forgotten immediately; no need
|
||||
// for ownership of it
|
||||
false
|
||||
}
|
||||
|
||||
fn postlude(ret: &str) -> impl Display {
|
||||
display!(
|
||||
"local {ret}_buf = {ret}; {ret} = __intern({ret}.__ptr, {ret}.__len); __C.{DROP_BUFFER_FN}({ret}_buf); "
|
||||
"do local __{ret} = {ret}; {ret} = __intern({ret}.__ptr, {ret}.__len); __C.{DROP_BUFFER_FN}(__{ret}); end; "
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,7 @@
|
||||
[package]
|
||||
name = "luaffi_impl"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
|
@ -24,7 +24,7 @@ pub fn transform(_args: Args, mut item: Item) -> Result<TokenStream> {
|
||||
|
||||
let mod_name = format_ident!("__{name}_cdef");
|
||||
|
||||
Ok(quote_spanned!(name.span() =>
|
||||
Ok(quote!(
|
||||
#[repr(C)]
|
||||
#[allow(non_camel_case_types)]
|
||||
#item
|
||||
|
@ -1,6 +1,5 @@
|
||||
use crate::utils::{
|
||||
StringLike, ffi_crate, is_optionlike, is_primitivelike, is_stringlike, is_unit, pat_ident,
|
||||
syn_assert, syn_error, ty_name,
|
||||
ffi_crate, is_primitivelike, is_unit, pat_ident, syn_assert, syn_error, ty_name,
|
||||
};
|
||||
use proc_macro2::TokenStream;
|
||||
use quote::{ToTokens, format_ident, quote, quote_spanned};
|
||||
@ -17,7 +16,7 @@ pub fn transform(mut imp: ItemImpl) -> Result<TokenStream> {
|
||||
let impls = generate_impls(&mut imp)?;
|
||||
let mod_name = format_ident!("__{}_metatype", ty_name(&imp.self_ty)?);
|
||||
|
||||
Ok(quote_spanned!(imp.self_ty.span() =>
|
||||
Ok(quote!(
|
||||
#imp
|
||||
|
||||
#[doc(hidden)]
|
||||
@ -30,27 +29,12 @@ pub fn transform(mut imp: ItemImpl) -> Result<TokenStream> {
|
||||
))
|
||||
}
|
||||
|
||||
struct Registry {
|
||||
ty: Ident,
|
||||
shims: Vec<ImplItemFn>,
|
||||
build: Vec<TokenStream>,
|
||||
}
|
||||
|
||||
impl Registry {
|
||||
fn new(ty: Ident) -> Self {
|
||||
Self {
|
||||
ty,
|
||||
shims: vec![],
|
||||
build: vec![],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn generate_impls(imp: &mut ItemImpl) -> Result<TokenStream> {
|
||||
let ffi = ffi_crate();
|
||||
let ty = imp.self_ty.clone();
|
||||
let ty_name = ty_name(&ty)?;
|
||||
let mut registry = Registry::new(ty_name.clone());
|
||||
let mut ffi_funcs = FfiRegistry::new(ty_name.clone());
|
||||
let mut lua_funcs = LuaRegistry::new(ty_name.clone());
|
||||
let mut mms = HashSet::new();
|
||||
let mut lua_drop = None;
|
||||
|
||||
@ -63,7 +47,7 @@ fn generate_impls(imp: &mut ItemImpl) -> Result<TokenStream> {
|
||||
);
|
||||
}
|
||||
|
||||
add_ffi_function(&mut registry, &func)?;
|
||||
add_ffi_function(&mut ffi_funcs, &func)?;
|
||||
}
|
||||
|
||||
for func in get_lua_functions(imp)? {
|
||||
@ -75,33 +59,38 @@ fn generate_impls(imp: &mut ItemImpl) -> Result<TokenStream> {
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(Metamethod::Gc) = func.attrs.metamethod {
|
||||
if func.attrs.metamethod == Some(Metamethod::Gc) {
|
||||
lua_drop = Some(func);
|
||||
} else {
|
||||
add_lua_function(&mut registry, &func)?;
|
||||
add_lua_function(&mut lua_funcs, &func)?;
|
||||
}
|
||||
}
|
||||
|
||||
if !mms.contains(&Metamethod::New) {
|
||||
inject_fallback_new(&mut registry)?;
|
||||
inject_fallback_new(&mut lua_funcs)?;
|
||||
}
|
||||
|
||||
inject_merged_drop(&mut registry, lua_drop.as_ref())?;
|
||||
inject_merged_drop(&mut ffi_funcs, lua_drop.as_ref())?;
|
||||
|
||||
let shims = ®istry.shims;
|
||||
let build = ®istry.build;
|
||||
let exports = generate_ffi_exports(®istry)?;
|
||||
let ffi_shims = &ffi_funcs.shims;
|
||||
let ffi_build = &ffi_funcs.build;
|
||||
let lua_build = &lua_funcs.build;
|
||||
let ffi_exports = generate_ffi_exports(&ffi_funcs)?;
|
||||
|
||||
Ok(quote_spanned!(ty.span() =>
|
||||
impl #ty { #(#shims)* }
|
||||
Ok(quote! {
|
||||
impl #ty { #(#ffi_shims)* }
|
||||
|
||||
unsafe impl #ffi::Metatype for #ty {
|
||||
type Target = Self;
|
||||
fn build(b: &mut #ffi::MetatypeBuilder) { #(#build)* }
|
||||
|
||||
fn build(b: &mut #ffi::MetatypeBuilder) {
|
||||
#(#ffi_build)*
|
||||
#(#lua_build)*
|
||||
}
|
||||
}
|
||||
|
||||
#exports
|
||||
))
|
||||
#ffi_exports
|
||||
})
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
@ -212,15 +201,9 @@ fn get_ffi_functions(imp: &mut ItemImpl) -> Result<Vec<FfiFunction>> {
|
||||
&& let Some(ref abi) = abi.name
|
||||
&& abi.value() == "Lua-C"
|
||||
{
|
||||
syn_assert!(
|
||||
func.sig.generics.params.len() == 0,
|
||||
func.sig.generics,
|
||||
"cannot be generic"
|
||||
);
|
||||
|
||||
func.sig.abi = None;
|
||||
|
||||
let params: Vec<_> = func
|
||||
let params = func
|
||||
.sig
|
||||
.inputs
|
||||
.iter()
|
||||
@ -238,29 +221,9 @@ fn get_ffi_functions(imp: &mut ItemImpl) -> Result<Vec<FfiFunction>> {
|
||||
ReturnType::Type(_, ref ty) => (**ty).clone(),
|
||||
};
|
||||
|
||||
for param in params.iter() {
|
||||
// double underscores are reserved for generated glue code
|
||||
syn_assert!(
|
||||
!pat_ident(¶m.pat)?.to_string().starts_with("__"),
|
||||
param.pat,
|
||||
"parameter names should not start with `__`"
|
||||
);
|
||||
|
||||
// lifetime should be determined by the caller (lua)
|
||||
if let Type::Reference(ref ty) = *param.ty {
|
||||
syn_assert!(
|
||||
ty.lifetime.is_none(),
|
||||
ty.lifetime,
|
||||
"lifetime should be determined by the caller"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let attrs = parse_ffi_function_attrs(&mut func.attrs)?;
|
||||
attrs.metamethod.map(|mm| document_metamethod(func, mm));
|
||||
|
||||
document_ffi_function(func);
|
||||
|
||||
funcs.push(FfiFunction {
|
||||
name: func.sig.ident.clone(),
|
||||
is_async: func.sig.asyncness.is_some(),
|
||||
@ -296,26 +259,14 @@ fn parse_ffi_function_attrs(attrs: &mut Vec<Attribute>) -> Result<FfiFunctionAtt
|
||||
Ok(parsed)
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
enum FfiParameterType {
|
||||
Default,
|
||||
StringLike(StringLike),
|
||||
OptionStringLike(StringLike),
|
||||
}
|
||||
|
||||
fn get_ffi_param_type(ty: &Type) -> FfiParameterType {
|
||||
if let Some(str) = is_stringlike(ty) {
|
||||
FfiParameterType::StringLike(str)
|
||||
} else if let Some(arg) = is_optionlike(ty)
|
||||
&& let Some(str) = is_stringlike(arg)
|
||||
{
|
||||
FfiParameterType::OptionStringLike(str)
|
||||
} else {
|
||||
fn get_ffi_param_type(_ty: &Type) -> FfiParameterType {
|
||||
FfiParameterType::Default
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
enum FfiReturnType {
|
||||
Void,
|
||||
ByValue,
|
||||
@ -345,7 +296,23 @@ fn get_ffi_ret_type(ty: &Type) -> FfiReturnType {
|
||||
}
|
||||
}
|
||||
|
||||
fn add_ffi_function(registry: &mut Registry, func: &FfiFunction) -> Result<()> {
|
||||
struct FfiRegistry {
|
||||
ty: Ident,
|
||||
shims: Vec<ImplItemFn>,
|
||||
build: Vec<TokenStream>,
|
||||
}
|
||||
|
||||
impl FfiRegistry {
|
||||
fn new(ty: Ident) -> Self {
|
||||
Self {
|
||||
ty,
|
||||
shims: vec![],
|
||||
build: vec![],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn add_ffi_function(registry: &mut FfiRegistry, func: &FfiFunction) -> Result<()> {
|
||||
let ffi = ffi_crate();
|
||||
let ty = ®istry.ty;
|
||||
let func_name = &func.name;
|
||||
@ -397,41 +364,6 @@ fn add_ffi_function(registry: &mut Registry, func: &FfiFunction) -> Result<()> {
|
||||
b.param::<#func_param>(#name);
|
||||
));
|
||||
}
|
||||
ty @ (FfiParameterType::StringLike(str) | FfiParameterType::OptionStringLike(str)) => {
|
||||
let shim_param_len = format_ident!("arg{i}_len");
|
||||
shim_params.push(quote_spanned!(func_param.span() =>
|
||||
#shim_param: ::std::option::Option<&::std::primitive::u8>,
|
||||
#shim_param_len: ::std::primitive::usize
|
||||
));
|
||||
let allow_nil = matches!(ty, FfiParameterType::OptionStringLike(_));
|
||||
let check_utf8 = matches!(str, StringLike::Str);
|
||||
let mut func_arg = quote_spanned!(func_param.span() =>
|
||||
#shim_param.map(|s| ::std::slice::from_raw_parts(s, #shim_param_len))
|
||||
);
|
||||
func_arg = match str {
|
||||
StringLike::SliceU8 => func_arg,
|
||||
StringLike::BStr => {
|
||||
quote_spanned!(func_param.span() => #func_arg.map(::bstr::BStr::new))
|
||||
}
|
||||
StringLike::Str => {
|
||||
quote_spanned!(func_param.span() => #func_arg.map(|s| {
|
||||
::std::debug_assert!(::std::str::from_utf8(s).is_ok());
|
||||
::std::str::from_utf8_unchecked(s)
|
||||
}))
|
||||
}
|
||||
};
|
||||
if !allow_nil {
|
||||
func_arg = quote_spanned!(func_param.span() => {
|
||||
let arg = #func_arg;
|
||||
::std::debug_assert!(arg.is_some());
|
||||
arg.unwrap_unchecked()
|
||||
});
|
||||
}
|
||||
func_args.push(func_arg);
|
||||
build.push(quote_spanned!(param.pat.span() =>
|
||||
b.param_str(#name, #allow_nil, #check_utf8);
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -460,12 +392,8 @@ fn add_ffi_function(registry: &mut Registry, func: &FfiFunction) -> Result<()> {
|
||||
<#func_ret as #ffi::IntoFfi>::convention() == #ffi::FfiReturnConvention::ByOutParam
|
||||
));
|
||||
|
||||
shim_params.insert(0, quote_spanned!(func_ret.span() => out: *mut #shim_ret));
|
||||
|
||||
(shim_body, shim_ret) = (
|
||||
quote_spanned!(func_ret.span() => ::std::ptr::write(out, #shim_body)),
|
||||
quote_spanned!(func_ret.span() => ()),
|
||||
);
|
||||
shim_params.insert(0, quote!(out: *mut #shim_ret));
|
||||
(shim_body, shim_ret) = (quote!(::std::ptr::write(out, #shim_body)), quote!(()));
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -489,23 +417,19 @@ fn add_ffi_function(registry: &mut Registry, func: &FfiFunction) -> Result<()> {
|
||||
));
|
||||
|
||||
registry.build.push(match func.attrs.metamethod {
|
||||
Some(ref mm) => quote_spanned!(func_name.span() =>
|
||||
b.metatable(#mm, |b| { #(#build)* });
|
||||
),
|
||||
None => quote_spanned!(func_name.span() =>
|
||||
b.index(#lua_name, |b| { #(#build)* });
|
||||
),
|
||||
Some(ref mm) => quote!(b.metatable(#mm, |b| { #(#build)* });),
|
||||
None => quote!(b.index(#lua_name, |b| { #(#build)* });),
|
||||
});
|
||||
|
||||
registry.shims.push(parse_quote_spanned!(func_name.span() =>
|
||||
#[unsafe(export_name = #c_name)]
|
||||
unsafe extern "C" fn #shim_name(#(#shim_params),*) -> #shim_ret { unsafe { #shim_body } }
|
||||
unsafe extern "C" fn #shim_name(#(#shim_params),*) -> #shim_ret { #shim_body }
|
||||
));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn generate_ffi_exports(registry: &Registry) -> Result<TokenStream> {
|
||||
fn generate_ffi_exports(registry: &FfiRegistry) -> Result<TokenStream> {
|
||||
let ty = ®istry.ty;
|
||||
let names = registry.shims.iter().map(|f| &f.sig.ident);
|
||||
|
||||
@ -540,12 +464,6 @@ fn get_lua_functions(imp: &mut ItemImpl) -> Result<Vec<LuaFunction>> {
|
||||
&& let Some(ref abi) = abi.name
|
||||
&& abi.value() == "Lua"
|
||||
{
|
||||
syn_assert!(
|
||||
func.sig.generics.params.len() == 0,
|
||||
func.sig.generics,
|
||||
"cannot be generic"
|
||||
);
|
||||
|
||||
let mut params: Vec<_> = func
|
||||
.sig
|
||||
.inputs
|
||||
@ -567,8 +485,6 @@ fn get_lua_functions(imp: &mut ItemImpl) -> Result<Vec<LuaFunction>> {
|
||||
let attrs = parse_lua_function_attrs(&mut func.attrs)?;
|
||||
attrs.metamethod.map(|mm| document_metamethod(func, mm));
|
||||
|
||||
document_lua_function(func);
|
||||
|
||||
funcs.push(LuaFunction {
|
||||
name: func.sig.ident.clone(),
|
||||
params,
|
||||
@ -590,10 +506,9 @@ fn stub_lua_function(func: &mut ImplItemFn) -> Result<()> {
|
||||
// documentation generation
|
||||
func.sig.abi = None;
|
||||
func.attrs.push(parse_quote!(#[allow(unused)]));
|
||||
func.block.stmts.clear();
|
||||
func.block.stmts.push(parse_quote!(
|
||||
func.block = parse_quote!({
|
||||
::std::unreachable!("cannot call lua function from rust");
|
||||
));
|
||||
});
|
||||
|
||||
let inputs = &mut func.sig.inputs;
|
||||
let output = &mut func.sig.output;
|
||||
@ -669,27 +584,63 @@ fn parse_lua_function_attrs(attrs: &mut Vec<Attribute>) -> Result<LuaFunctionAtt
|
||||
Ok(parsed)
|
||||
}
|
||||
|
||||
fn add_lua_function(registry: &mut Registry, func: &LuaFunction) -> Result<()> {
|
||||
struct LuaRegistry {
|
||||
ty: Ident,
|
||||
build: Vec<TokenStream>,
|
||||
}
|
||||
|
||||
impl LuaRegistry {
|
||||
fn new(ty: Ident) -> Self {
|
||||
Self { ty, build: vec![] }
|
||||
}
|
||||
}
|
||||
|
||||
fn add_lua_function(registry: &mut LuaRegistry, func: &LuaFunction) -> Result<()> {
|
||||
let ffi = ffi_crate();
|
||||
let luaify = quote!(#ffi::__internal::luaify!);
|
||||
let func_name = &func.name;
|
||||
let name = func.name.unraw().to_string();
|
||||
let params = &func.params;
|
||||
let body = &func.body;
|
||||
let name = func_name.unraw().to_string();
|
||||
|
||||
registry.build.push(match func.attrs.metamethod {
|
||||
Some(ref mm) => quote_spanned!(func_name.span() =>
|
||||
b.metatable_raw(#mm, #luaify(|#(#params),*| #body));
|
||||
),
|
||||
None => quote_spanned!(func_name.span() =>
|
||||
b.index_raw(#name, #luaify(|#(#params),*| #body));
|
||||
),
|
||||
Some(ref mm) => quote!(b.metatable_raw(#mm, #luaify(|#(#params),*| #body));),
|
||||
None => quote!(b.index_raw(#name, #luaify(|#(#params),*| #body));),
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn inject_fallback_new(registry: &mut Registry) -> Result<()> {
|
||||
fn document_metamethod(func: &mut ImplItemFn, method: Metamethod) {
|
||||
let s = match method {
|
||||
Metamethod::Eq => "This is a metamethod which is called by the `==` operator.".into(),
|
||||
Metamethod::Len => "This is a metamethod which is called by the `#` operator.".into(),
|
||||
Metamethod::Lt => "This is a metamethod which is called by the `<` operator.".into(),
|
||||
Metamethod::Le => "This is a metamethod which is called by the `<=` operator.".into(),
|
||||
Metamethod::Concat => "This is a metamethod which is called by the `..` operator.".into(),
|
||||
Metamethod::Add => "This is a metamethod which is called by the `+` operator.".into(),
|
||||
Metamethod::Sub => "This is a metamethod which is called by the `-` operator.".into(),
|
||||
Metamethod::Mul => "This is a metamethod which is called by the `*` operator.".into(),
|
||||
Metamethod::Div => "This is a metamethod which is called by the `/` operator.".into(),
|
||||
Metamethod::Mod => "This is a metamethod which is called by the `%` operator.".into(),
|
||||
Metamethod::Pow => "This is a metamethod which is called by the `^` operator.".into(),
|
||||
Metamethod::Unm => "This is a metamethod which is called by the `-` operator.".into(),
|
||||
Metamethod::ToString => {
|
||||
"This is a metamethod which can be called by the `tostring` built-in function.".into()
|
||||
}
|
||||
Metamethod::Pairs => {
|
||||
"This is a metamethod which can be called by the `pairs` built-in function.".into()
|
||||
}
|
||||
Metamethod::Ipairs => {
|
||||
"This is a metamethod which can be called by the `ipairs` built-in function.".into()
|
||||
}
|
||||
_ => format!("This is a metamethod and cannot be called directly."),
|
||||
};
|
||||
|
||||
func.attrs.push(parse_quote!(#[doc = ""]));
|
||||
func.attrs.push(parse_quote!(#[doc = #s]));
|
||||
}
|
||||
|
||||
fn inject_fallback_new(registry: &mut LuaRegistry) -> Result<()> {
|
||||
let ty = ®istry.ty;
|
||||
let lua = format!(
|
||||
r#"function() error("type '{}' has no constructor"); end"#,
|
||||
@ -703,7 +654,7 @@ fn inject_fallback_new(registry: &mut Registry) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn inject_merged_drop(registry: &mut Registry, lua: Option<&LuaFunction>) -> Result<()> {
|
||||
fn inject_merged_drop(registry: &mut FfiRegistry, lua: Option<&LuaFunction>) -> Result<()> {
|
||||
let ffi = ffi_crate();
|
||||
let luaify = quote!(#ffi::__internal::luaify!);
|
||||
let ty = ®istry.ty;
|
||||
@ -760,45 +711,3 @@ fn inject_merged_drop(registry: &mut Registry, lua: Option<&LuaFunction>) -> Res
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn document_ffi_function(func: &mut ImplItemFn) {
|
||||
func.attrs.insert(0, parse_quote!(#[doc =
|
||||
r#"<span class="stab" title="This is a C/FFI function." style="float: right; font-weight: 500; margin-left: 3px; padding-left: 5px; padding-right: 5px;">FFI</span>"#
|
||||
]));
|
||||
}
|
||||
|
||||
fn document_lua_function(func: &mut ImplItemFn) {
|
||||
func.attrs.insert(0, parse_quote!(#[doc =
|
||||
r#"<span class="stab" title="This is a Lua function." style="float: right; font-weight: 500; margin-left: 3px; padding-left: 5px; padding-right: 5px;">Lua</span>"#
|
||||
]));
|
||||
}
|
||||
|
||||
fn document_metamethod(func: &mut ImplItemFn, method: Metamethod) {
|
||||
let s = match method {
|
||||
Metamethod::Eq => "This is a metamethod which is called by the `==` operator.".into(),
|
||||
Metamethod::Len => "This is a metamethod which is called by the `#` operator.".into(),
|
||||
Metamethod::Lt => "This is a metamethod which is called by the `<` operator.".into(),
|
||||
Metamethod::Le => "This is a metamethod which is called by the `<=` operator.".into(),
|
||||
Metamethod::Concat => "This is a metamethod which is called by the `..` operator.".into(),
|
||||
Metamethod::Add => "This is a metamethod which is called by the `+` operator.".into(),
|
||||
Metamethod::Sub => "This is a metamethod which is called by the `-` operator.".into(),
|
||||
Metamethod::Mul => "This is a metamethod which is called by the `*` operator.".into(),
|
||||
Metamethod::Div => "This is a metamethod which is called by the `/` operator.".into(),
|
||||
Metamethod::Mod => "This is a metamethod which is called by the `%` operator.".into(),
|
||||
Metamethod::Pow => "This is a metamethod which is called by the `^` operator.".into(),
|
||||
Metamethod::Unm => "This is a metamethod which is called by the `-` operator.".into(),
|
||||
Metamethod::ToString => {
|
||||
"This is a metamethod which can be called by the `tostring` built-in function.".into()
|
||||
}
|
||||
Metamethod::Pairs => {
|
||||
"This is a metamethod which can be called by the `pairs` built-in function.".into()
|
||||
}
|
||||
Metamethod::Ipairs => {
|
||||
"This is a metamethod which can be called by the `ipairs` built-in function.".into()
|
||||
}
|
||||
_ => format!("This is a metamethod and cannot be called directly."),
|
||||
};
|
||||
|
||||
func.attrs.push(parse_quote!(#[doc = ""]));
|
||||
func.attrs.push(parse_quote!(#[doc = #s]));
|
||||
}
|
||||
|
@ -57,13 +57,13 @@ pub fn is_unit(ty: &Type) -> bool {
|
||||
|
||||
pub fn is_primitivelike(ty: &Type) -> bool {
|
||||
match ty {
|
||||
Type::Tuple(tuple) if tuple.elems.is_empty() => return true, // unit type
|
||||
Type::Reference(_) | Type::Ptr(_) => return true,
|
||||
Type::Paren(paren) => return is_primitivelike(&paren.elem),
|
||||
Type::Tuple(tuple) if tuple.elems.is_empty() => true, // unit type
|
||||
Type::Reference(_) | Type::Ptr(_) => true,
|
||||
Type::Paren(paren) => is_primitivelike(&paren.elem),
|
||||
Type::Path(path) => {
|
||||
if let Some(name) = path.path.get_ident() {
|
||||
return matches!(
|
||||
name.to_string().as_str(),
|
||||
matches!(
|
||||
format!("{name}").as_str(),
|
||||
"bool"
|
||||
| "u8"
|
||||
| "u16"
|
||||
@ -94,66 +94,11 @@ pub fn is_primitivelike(ty: &Type) -> bool {
|
||||
| "c_size_t"
|
||||
| "c_ssize_t"
|
||||
| "c_ptrdiff_t"
|
||||
);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum StringLike {
|
||||
SliceU8,
|
||||
Str,
|
||||
BStr,
|
||||
}
|
||||
|
||||
pub fn is_stringlike(ty: &Type) -> Option<StringLike> {
|
||||
if let Type::Reference(ty) = ty
|
||||
&& ty.mutability.is_none()
|
||||
&& ty.lifetime.is_none()
|
||||
{
|
||||
match *ty.elem {
|
||||
Type::Slice(ref slice) => {
|
||||
// match &[u8]
|
||||
if let Type::Path(ref path) = *slice.elem
|
||||
&& let Some(name) = path.path.get_ident()
|
||||
&& name == "u8"
|
||||
{
|
||||
return Some(StringLike::SliceU8);
|
||||
}
|
||||
}
|
||||
Type::Path(ref path) => {
|
||||
// match &str or &BStr
|
||||
if let Some(name) = path.path.get_ident() {
|
||||
match name.to_string().as_str() {
|
||||
"str" => return Some(StringLike::Str),
|
||||
"BStr" => return Some(StringLike::BStr),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
pub fn is_optionlike(ty: &Type) -> Option<&Type> {
|
||||
if let Type::Path(path) = ty
|
||||
&& path.path.leading_colon.is_none()
|
||||
&& path.path.segments.len() == 1
|
||||
&& let Some(segment) = path.path.segments.get(0)
|
||||
&& segment.ident == "Option"
|
||||
&& let PathArguments::AngleBracketed(ref angle) = segment.arguments
|
||||
&& angle.args.len() == 1
|
||||
&& let Some(GenericArgument::Type(ty)) = angle.args.get(0)
|
||||
{
|
||||
Some(ty)
|
||||
} else {
|
||||
None
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,7 @@
|
||||
[package]
|
||||
name = "luaify"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
|
@ -1,11 +1,7 @@
|
||||
[package]
|
||||
name = "luajit-sys"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[lib]
|
||||
path = "lib.rs"
|
||||
|
@ -1,11 +1,7 @@
|
||||
[package]
|
||||
name = "luajit"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[features]
|
||||
runtime = ["luajit-sys/runtime"]
|
||||
@ -14,6 +10,6 @@ unwind = ["luajit-sys/unwind"]
|
||||
[dependencies]
|
||||
bitflags = { version = "2.9.1", features = ["std"] }
|
||||
bstr = "1.12.0"
|
||||
luaffi = { path = "../luaffi" }
|
||||
luajit-sys = { path = "../luajit-sys" }
|
||||
luaffi = { version = "0.1.0", path = "../luaffi" }
|
||||
luajit-sys = { version = "0.1.0", path = "../luajit-sys" }
|
||||
thiserror = "2.0.12"
|
||||
|
@ -25,16 +25,6 @@ pub fn version() -> &'static str {
|
||||
LUAJIT_VERSION.to_str().unwrap()
|
||||
}
|
||||
|
||||
/// LuaJIT copyright string.
|
||||
pub fn copyright() -> &'static str {
|
||||
LUAJIT_COPYRIGHT.to_str().unwrap()
|
||||
}
|
||||
|
||||
/// LuaJIT URL string.
|
||||
pub fn url() -> &'static str {
|
||||
LUAJIT_URL.to_str().unwrap()
|
||||
}
|
||||
|
||||
/// Lua error.
|
||||
#[derive(Debug, Error)]
|
||||
#[non_exhaustive]
|
||||
@ -1343,7 +1333,8 @@ impl<'s> DerefMut for StackGuard<'s> {
|
||||
|
||||
impl<'s> Drop for StackGuard<'s> {
|
||||
fn drop(&mut self) {
|
||||
if cfg!(debug_assertions) && self.check_overpop {
|
||||
#[cfg(debug_assertions)]
|
||||
if self.check_overpop {
|
||||
let new_size = self.stack.size();
|
||||
assert!(
|
||||
self.size <= new_size,
|
||||
|
51
src/main.rs
51
src/main.rs
@ -30,10 +30,7 @@ fn panic_cb(panic: &panic::PanicHookInfo) {
|
||||
|
||||
eprintln!(
|
||||
"{}",
|
||||
format_args!(
|
||||
"This is a bug in luby. Please kindly report this at {}.",
|
||||
env!("CARGO_PKG_REPOSITORY")
|
||||
)
|
||||
"This is a bug in luby. Please kindly report this at https://git.lua.re/luaneko/luby."
|
||||
.yellow()
|
||||
);
|
||||
}
|
||||
@ -48,7 +45,7 @@ struct Args {
|
||||
#[clap(long, short = 'e', value_name = "CHUNK")]
|
||||
eval: Vec<String>,
|
||||
|
||||
/// Libraries to require.
|
||||
/// Libraries to require on startup.
|
||||
#[clap(long, short = 'l', value_name = "NAME")]
|
||||
lib: Vec<String>,
|
||||
|
||||
@ -57,45 +54,29 @@ struct Args {
|
||||
log: tracing::Level,
|
||||
|
||||
/// LuaJIT control commands.
|
||||
#[clap(long, short = 'j', help_heading = "Runtime", value_name = "CMD=FLAGS")]
|
||||
#[clap(long, short = 'j', value_name = "CMD=FLAGS")]
|
||||
jit: Vec<String>,
|
||||
|
||||
/// Number of worker threads.
|
||||
#[clap(
|
||||
long,
|
||||
short = 'T',
|
||||
help_heading = "Runtime",
|
||||
value_name = "THREADS",
|
||||
default_value_t = Self::threads()
|
||||
)]
|
||||
/// Number of tokio worker threads.
|
||||
#[clap(long, value_name = "THREADS", default_value_t = Self::threads())]
|
||||
threads: NonZero<usize>,
|
||||
|
||||
/// Number of blocking threads.
|
||||
#[clap(
|
||||
long,
|
||||
help_heading = "Runtime",
|
||||
value_name = "THREADS",
|
||||
default_value_t = Self::blocking_threads()
|
||||
)]
|
||||
/// Number of tokio blocking threads.
|
||||
#[clap(long, value_name = "THREADS", default_value_t = Self::blocking_threads())]
|
||||
blocking_threads: NonZero<usize>,
|
||||
|
||||
/// Enable tokio-console integration.
|
||||
#[clap(long, help_heading = "Debugging")]
|
||||
#[clap(long)]
|
||||
enable_console: bool,
|
||||
|
||||
/// tokio-console publish address.
|
||||
#[clap(
|
||||
long,
|
||||
help_heading = "Debugging",
|
||||
value_name = "ADDRESS",
|
||||
default_value = "127.0.0.1:6669",
|
||||
requires = "enable_console"
|
||||
)]
|
||||
console_addr: SocketAddr,
|
||||
|
||||
/// Print version.
|
||||
#[clap(long, short = 'V')]
|
||||
version: bool,
|
||||
}
|
||||
|
||||
impl Args {
|
||||
@ -119,10 +100,6 @@ fn main() -> Result<(), ExitCode> {
|
||||
panic::set_hook(Box::new(panic_cb));
|
||||
|
||||
let args = Args::parse();
|
||||
if args.version {
|
||||
return Ok(print_version());
|
||||
}
|
||||
|
||||
init_logger(&args);
|
||||
|
||||
let tokio = init_tokio(&args);
|
||||
@ -135,18 +112,6 @@ fn main() -> Result<(), ExitCode> {
|
||||
})
|
||||
}
|
||||
|
||||
fn print_version() {
|
||||
println!("luby {}", env!("VERGEN_GIT_DESCRIBE"));
|
||||
println!("{}\n", env!("CARGO_PKG_HOMEPAGE"));
|
||||
println!("Compiled with {} -- {}", luajit::version(), luajit::url());
|
||||
println!(
|
||||
"Compiled with rustc {} on {} for {}",
|
||||
env!("VERGEN_RUSTC_SEMVER"),
|
||||
env!("VERGEN_RUSTC_HOST_TRIPLE"),
|
||||
env!("VERGEN_CARGO_TARGET_TRIPLE"),
|
||||
);
|
||||
}
|
||||
|
||||
fn init_logger(args: &Args) {
|
||||
use tracing::level_filters::LevelFilter;
|
||||
use tracing_subscriber::{Layer, util::*};
|
||||
|
Loading…
x
Reference in New Issue
Block a user