Merge branch 'main' into feature/sched-return

This commit is contained in:
Erica Marigold 2024-05-15 18:30:56 +05:30 committed by GitHub
commit 7cd9892325
Signed by: DevComp
GPG key ID: B5690EEEBB952194
10 changed files with 86 additions and 53 deletions

View file

@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## `0.8.4` - May 12th, 2024 ## `0.8.4` - May 12th, 2024
### Changed ### Added
- Added a builtin API for regular expressions. - Added a builtin API for regular expressions.
@ -51,6 +51,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Currently supported targets are the same as the ones included with each Currently supported targets are the same as the ones included with each
release of Lune on GitHub. Check releases for a full list of targets. release of Lune on GitHub. Check releases for a full list of targets.
- Added `stdio.readToEnd()` for reading the entire stdin passed to Lune
### Changed
- Split the repository into modular crates instead of a monolith. ([#188]) - Split the repository into modular crates instead of a monolith. ([#188])
If you previously depended on Lune as a crate, nothing about it has changed for version `0.8.4`, but now each individual sub-crate has also been published and is available for use: If you previously depended on Lune as a crate, nothing about it has changed for version `0.8.4`, but now each individual sub-crate has also been published and is available for use:
@ -64,7 +68,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
In general, this should mean that it is now much easier to make your own Lune builtin, publish your own flavor of a Lune CLI, or take advantage of all the work that has been done for Lune as a runtime when making your own Rust programs. In general, this should mean that it is now much easier to make your own Lune builtin, publish your own flavor of a Lune CLI, or take advantage of all the work that has been done for Lune as a runtime when making your own Rust programs.
- Added `stdio.readToEnd()` for reading the entire stdin passed to Lune
- Changed the `User-Agent` header in `net.request` to be more descriptive ([#186]) - Changed the `User-Agent` header in `net.request` to be more descriptive ([#186])
- Updated to Luau version `0.622`. - Updated to Luau version `0.622`.

42
Cargo.lock generated
View file

@ -412,9 +412,9 @@ checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
[[package]] [[package]]
name = "chrono" name = "chrono"
version = "0.4.34" version = "0.4.38"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401"
dependencies = [ dependencies = [
"android-tzdata", "android-tzdata",
"iana-time-zone", "iana-time-zone",
@ -426,9 +426,9 @@ dependencies = [
[[package]] [[package]]
name = "chrono_lc" name = "chrono_lc"
version = "0.1.5" version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "809c968b91b4949802fba00279fd0610158cbb2ae5f10663f0c3d5331f88d6d6" checksum = "aa1812634894df89eb9d5075eba0b97d42b4affe477bde7d0db3d2cf8454a800"
dependencies = [ dependencies = [
"chrono", "chrono",
"lazy_static", "lazy_static",
@ -779,29 +779,6 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d"
[[package]]
name = "env_filter"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea"
dependencies = [
"log",
"regex",
]
[[package]]
name = "env_logger"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9"
dependencies = [
"anstream",
"anstyle",
"env_filter",
"humantime",
"log",
]
[[package]] [[package]]
name = "equivalent" name = "equivalent"
version = "1.0.1" version = "1.0.1"
@ -1182,12 +1159,6 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
[[package]]
name = "humantime"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]] [[package]]
name = "hyper" name = "hyper"
version = "0.14.28" version = "0.14.28"
@ -1478,7 +1449,6 @@ dependencies = [
"console", "console",
"dialoguer", "dialoguer",
"directories", "directories",
"env_logger",
"futures-util", "futures-util",
"include_dir", "include_dir",
"lune-roblox", "lune-roblox",
@ -1517,7 +1487,7 @@ dependencies = [
[[package]] [[package]]
name = "lune-std" name = "lune-std"
version = "0.1.0" version = "0.1.1"
dependencies = [ dependencies = [
"lune-std-datetime", "lune-std-datetime",
"lune-std-fs", "lune-std-fs",
@ -1539,7 +1509,7 @@ dependencies = [
[[package]] [[package]]
name = "lune-std-datetime" name = "lune-std-datetime"
version = "0.1.0" version = "0.1.1"
dependencies = [ dependencies = [
"chrono", "chrono",
"chrono_lc", "chrono_lc",

View file

@ -80,6 +80,7 @@ impl LuaUserData for Vector2 {
methods.add_meta_method(LuaMetaMethod::Sub, userdata_impl_sub); methods.add_meta_method(LuaMetaMethod::Sub, userdata_impl_sub);
methods.add_meta_method(LuaMetaMethod::Mul, userdata_impl_mul_f32); methods.add_meta_method(LuaMetaMethod::Mul, userdata_impl_mul_f32);
methods.add_meta_method(LuaMetaMethod::Div, userdata_impl_div_f32); methods.add_meta_method(LuaMetaMethod::Div, userdata_impl_div_f32);
methods.add_meta_method(LuaMetaMethod::IDiv, userdata_impl_idiv_f32);
} }
} }
@ -138,6 +139,20 @@ impl ops::Div<f32> for Vector2 {
} }
} }
impl IDiv for Vector2 {
type Output = Vector2;
fn idiv(self, rhs: Self) -> Self::Output {
Self((self.0 / rhs.0).floor())
}
}
impl IDiv<f32> for Vector2 {
type Output = Vector2;
fn idiv(self, rhs: f32) -> Self::Output {
Self((self.0 / rhs).floor())
}
}
impl From<DomVector2> for Vector2 { impl From<DomVector2> for Vector2 {
fn from(v: DomVector2) -> Self { fn from(v: DomVector2) -> Self {
Vector2(Vec2 { x: v.x, y: v.y }) Vector2(Vec2 { x: v.x, y: v.y })

View file

@ -141,6 +141,7 @@ impl LuaUserData for Vector3 {
methods.add_meta_method(LuaMetaMethod::Sub, userdata_impl_sub); methods.add_meta_method(LuaMetaMethod::Sub, userdata_impl_sub);
methods.add_meta_method(LuaMetaMethod::Mul, userdata_impl_mul_f32); methods.add_meta_method(LuaMetaMethod::Mul, userdata_impl_mul_f32);
methods.add_meta_method(LuaMetaMethod::Div, userdata_impl_div_f32); methods.add_meta_method(LuaMetaMethod::Div, userdata_impl_div_f32);
methods.add_meta_method(LuaMetaMethod::IDiv, userdata_impl_idiv_f32);
} }
} }
@ -199,6 +200,20 @@ impl ops::Div<f32> for Vector3 {
} }
} }
impl IDiv for Vector3 {
type Output = Vector3;
fn idiv(self, rhs: Self) -> Self::Output {
Self((self.0 / rhs.0).floor())
}
}
impl IDiv<f32> for Vector3 {
type Output = Vector3;
fn idiv(self, rhs: f32) -> Self::Output {
Self((self.0 / rhs).floor())
}
}
impl From<DomVector3> for Vector3 { impl From<DomVector3> for Vector3 {
fn from(v: DomVector3) -> Self { fn from(v: DomVector3) -> Self {
Vector3(Vec3 { Vector3(Vec3 {

View file

@ -149,6 +149,37 @@ where
}) })
} }
pub trait IDiv<Rhs = Self> {
type Output;
#[must_use]
fn idiv(self, rhs: Rhs) -> Self::Output;
}
pub fn userdata_impl_idiv_f32<D>(_: &Lua, datatype: &D, rhs: LuaValue) -> LuaResult<D>
where
D: LuaUserData + IDiv<D, Output = D> + IDiv<f32, Output = D> + Copy + 'static,
{
match &rhs {
LuaValue::Number(n) => return Ok(datatype.idiv(*n as f32)),
LuaValue::Integer(i) => return Ok(datatype.idiv(*i as f32)),
LuaValue::UserData(ud) => {
if let Ok(vec) = ud.borrow::<D>() {
return Ok(datatype.idiv(*vec));
}
}
_ => {}
};
Err(LuaError::FromLuaConversionError {
from: rhs.type_name(),
to: type_name::<D>(),
message: Some(format!(
"Expected {} or number, got {}",
type_name::<D>(),
rhs.type_name()
)),
})
}
pub fn userdata_impl_div_i32<D>(_: &Lua, datatype: &D, rhs: LuaValue) -> LuaResult<D> pub fn userdata_impl_div_i32<D>(_: &Lua, datatype: &D, rhs: LuaValue) -> LuaResult<D>
where where
D: LuaUserData + ops::Div<D, Output = D> + ops::Div<i32, Output = D> + Copy + 'static, D: LuaUserData + ops::Div<D, Output = D> + ops::Div<i32, Output = D> + Copy + 'static,

View file

@ -1,6 +1,6 @@
[package] [package]
name = "lune-std-datetime" name = "lune-std-datetime"
version = "0.1.0" version = "0.1.1"
edition = "2021" edition = "2021"
license = "MPL-2.0" license = "MPL-2.0"
repository = "https://github.com/lune-org/lune" repository = "https://github.com/lune-org/lune"
@ -16,7 +16,7 @@ workspace = true
mlua = { version = "0.9.7", features = ["luau"] } mlua = { version = "0.9.7", features = ["luau"] }
thiserror = "1.0" thiserror = "1.0"
chrono = "=0.4.34" # NOTE: 0.4.35 does not compile with chrono_lc chrono = "0.4.38"
chrono_lc = "0.1" chrono_lc = "0.1.6"
lune-utils = { version = "0.1.0", path = "../lune-utils" } lune-utils = { version = "0.1.0", path = "../lune-utils" }

View file

@ -1,6 +1,6 @@
[package] [package]
name = "lune-std" name = "lune-std"
version = "0.1.0" version = "0.1.1"
edition = "2021" edition = "2021"
license = "MPL-2.0" license = "MPL-2.0"
repository = "https://github.com/lune-org/lune" repository = "https://github.com/lune-org/lune"
@ -47,7 +47,7 @@ tokio = { version = "1", default-features = false, features = ["fs", "sync"] }
lune-utils = { version = "0.1.0", path = "../lune-utils" } lune-utils = { version = "0.1.0", path = "../lune-utils" }
lune-std-datetime = { optional = true, version = "0.1.0", path = "../lune-std-datetime" } lune-std-datetime = { optional = true, version = "0.1.1", path = "../lune-std-datetime" }
lune-std-fs = { optional = true, version = "0.1.0", path = "../lune-std-fs" } lune-std-fs = { optional = true, version = "0.1.0", path = "../lune-std-fs" }
lune-std-luau = { optional = true, version = "0.1.0", path = "../lune-std-luau" } lune-std-luau = { optional = true, version = "0.1.0", path = "../lune-std-luau" }
lune-std-net = { optional = true, version = "0.1.0", path = "../lune-std-net" } lune-std-net = { optional = true, version = "0.1.0", path = "../lune-std-net" }

View file

@ -5,7 +5,7 @@ edition = "2021"
license = "MPL-2.0" license = "MPL-2.0"
repository = "https://github.com/lune-org/lune" repository = "https://github.com/lune-org/lune"
description = "A standalone Luau runtime" description = "A standalone Luau runtime"
readme = "README.md" readme = "../../README.md"
keywords = ["cli", "lua", "luau", "runtime"] keywords = ["cli", "lua", "luau", "runtime"]
categories = ["command-line-interface"] categories = ["command-line-interface"]
@ -44,13 +44,7 @@ std = [
"std-task", "std-task",
] ]
cli = [ cli = ["dep:clap", "dep:include_dir", "dep:rustyline", "dep:zip_next"]
"dep:env_logger",
"dep:clap",
"dep:include_dir",
"dep:rustyline",
"dep:zip_next",
]
[lints] [lints]
workspace = true workspace = true
@ -76,13 +70,12 @@ reqwest = { version = "0.11", default-features = false, features = [
"rustls-tls", "rustls-tls",
] } ] }
lune-std = { optional = true, version = "0.1.0", path = "../lune-std" } lune-std = { optional = true, version = "0.1.1", path = "../lune-std" }
lune-roblox = { optional = true, version = "0.1.0", path = "../lune-roblox" } lune-roblox = { optional = true, version = "0.1.0", path = "../lune-roblox" }
lune-utils = { version = "0.1.0", path = "../lune-utils" } lune-utils = { version = "0.1.0", path = "../lune-utils" }
### CLI ### CLI
env_logger = { optional = true, version = "0.11" }
clap = { optional = true, version = "4.1", features = ["derive"] } clap = { optional = true, version = "4.1", features = ["derive"] }
include_dir = { optional = true, version = "0.7", features = ["glob"] } include_dir = { optional = true, version = "0.7", features = ["glob"] }
rustyline = { optional = true, version = "14.0" } rustyline = { optional = true, version = "14.0" }

View file

@ -39,4 +39,7 @@ assert(Vector2.new(2, 4) / Vector2.new(1, 2) == Vector2.new(2, 2))
assert(Vector2.new(2, 4) * 2 == Vector2.new(4, 8)) assert(Vector2.new(2, 4) * 2 == Vector2.new(4, 8))
assert(Vector2.new(2, 4) / 2 == Vector2.new(1, 2)) assert(Vector2.new(2, 4) / 2 == Vector2.new(1, 2))
assert(Vector2.new(7, 15) // Vector2.new(3, 7) == Vector2.new(2, 2))
assert(Vector2.new(3, 7) // 2 == Vector2.new(1, 3))
-- TODO: Vector math -- TODO: Vector math

View file

@ -42,4 +42,7 @@ assert(Vector3.new(2, 4, 8) / Vector3.new(1, 1, 2) == Vector3.new(2, 4, 4))
assert(Vector3.new(2, 4, 8) * 2 == Vector3.new(4, 8, 16)) assert(Vector3.new(2, 4, 8) * 2 == Vector3.new(4, 8, 16))
assert(Vector3.new(2, 4, 8) / 2 == Vector3.new(1, 2, 4)) assert(Vector3.new(2, 4, 8) / 2 == Vector3.new(1, 2, 4))
assert(Vector3.new(7, 11, 15) // Vector3.new(3, 5, 7) == Vector3.new(2, 2, 2))
assert(Vector3.new(3, 5, 7) // 2 == Vector3.new(1, 2, 3))
-- TODO: Vector math -- TODO: Vector math