mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 13:00:37 +00:00
Rename rbx alisases to dom instead for roblox lib
This commit is contained in:
parent
5098b28ada
commit
560dc4acbe
27 changed files with 260 additions and 265 deletions
|
@ -1,21 +1,21 @@
|
|||
use mlua::prelude::*;
|
||||
|
||||
use rbx_dom_weak::types::{Variant as RbxVariant, VariantType as RbxVariantType};
|
||||
use rbx_dom_weak::types::{Variant as DomValue, VariantType as DomType};
|
||||
|
||||
use crate::datatypes::extension::RbxVariantExt;
|
||||
use crate::datatypes::extension::DomValueExt;
|
||||
|
||||
use super::*;
|
||||
|
||||
pub(crate) trait LuaToRbxVariant<'lua> {
|
||||
fn lua_to_rbx_variant(
|
||||
pub(crate) trait LuaToDomValue<'lua> {
|
||||
fn lua_to_dom_value(
|
||||
&self,
|
||||
lua: &'lua Lua,
|
||||
variant_type: RbxVariantType,
|
||||
) -> DatatypeConversionResult<RbxVariant>;
|
||||
variant_type: DomType,
|
||||
) -> DomConversionResult<DomValue>;
|
||||
}
|
||||
|
||||
pub(crate) trait RbxVariantToLua<'lua>: Sized {
|
||||
fn rbx_variant_to_lua(lua: &'lua Lua, variant: &RbxVariant) -> DatatypeConversionResult<Self>;
|
||||
pub(crate) trait DomValueToLua<'lua>: Sized {
|
||||
fn dom_value_to_lua(lua: &'lua Lua, variant: &DomValue) -> DomConversionResult<Self>;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -28,27 +28,26 @@ pub(crate) trait RbxVariantToLua<'lua>: Sized {
|
|||
|
||||
*/
|
||||
|
||||
impl<'lua> RbxVariantToLua<'lua> for LuaValue<'lua> {
|
||||
fn rbx_variant_to_lua(lua: &'lua Lua, variant: &RbxVariant) -> DatatypeConversionResult<Self> {
|
||||
impl<'lua> DomValueToLua<'lua> for LuaValue<'lua> {
|
||||
fn dom_value_to_lua(lua: &'lua Lua, variant: &DomValue) -> DomConversionResult<Self> {
|
||||
use base64::engine::general_purpose::STANDARD_NO_PAD;
|
||||
use base64::engine::Engine as _;
|
||||
|
||||
use rbx_dom_weak::types as rbx;
|
||||
use RbxVariant as Rbx;
|
||||
use rbx_dom_weak::types as dom;
|
||||
|
||||
match LuaAnyUserData::rbx_variant_to_lua(lua, variant) {
|
||||
match LuaAnyUserData::dom_value_to_lua(lua, variant) {
|
||||
Ok(value) => Ok(LuaValue::UserData(value)),
|
||||
Err(e) => match variant {
|
||||
Rbx::Bool(b) => Ok(LuaValue::Boolean(*b)),
|
||||
Rbx::Int64(i) => Ok(LuaValue::Number(*i as f64)),
|
||||
Rbx::Int32(i) => Ok(LuaValue::Number(*i as f64)),
|
||||
Rbx::Float64(n) => Ok(LuaValue::Number(*n)),
|
||||
Rbx::Float32(n) => Ok(LuaValue::Number(*n as f64)),
|
||||
Rbx::String(s) => Ok(LuaValue::String(lua.create_string(s)?)),
|
||||
Rbx::Content(s) => Ok(LuaValue::String(
|
||||
DomValue::Bool(b) => Ok(LuaValue::Boolean(*b)),
|
||||
DomValue::Int64(i) => Ok(LuaValue::Number(*i as f64)),
|
||||
DomValue::Int32(i) => Ok(LuaValue::Number(*i as f64)),
|
||||
DomValue::Float64(n) => Ok(LuaValue::Number(*n)),
|
||||
DomValue::Float32(n) => Ok(LuaValue::Number(*n as f64)),
|
||||
DomValue::String(s) => Ok(LuaValue::String(lua.create_string(s)?)),
|
||||
DomValue::Content(s) => Ok(LuaValue::String(
|
||||
lua.create_string(AsRef::<str>::as_ref(s))?,
|
||||
)),
|
||||
Rbx::BinaryString(s) => {
|
||||
DomValue::BinaryString(s) => {
|
||||
let encoded = STANDARD_NO_PAD.encode(AsRef::<[u8]>::as_ref(s));
|
||||
Ok(LuaValue::String(lua.create_string(&encoded)?))
|
||||
}
|
||||
|
@ -56,7 +55,7 @@ impl<'lua> RbxVariantToLua<'lua> for LuaValue<'lua> {
|
|||
// NOTE: We need this special case here to handle default (nil)
|
||||
// physical properties since our PhysicalProperties datatype
|
||||
// implementation does not handle default at all, only custom
|
||||
Rbx::PhysicalProperties(rbx::PhysicalProperties::Default) => Ok(LuaValue::Nil),
|
||||
DomValue::PhysicalProperties(dom::PhysicalProperties::Default) => Ok(LuaValue::Nil),
|
||||
|
||||
_ => Err(e),
|
||||
},
|
||||
|
@ -64,50 +63,48 @@ impl<'lua> RbxVariantToLua<'lua> for LuaValue<'lua> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'lua> LuaToRbxVariant<'lua> for LuaValue<'lua> {
|
||||
fn lua_to_rbx_variant(
|
||||
impl<'lua> LuaToDomValue<'lua> for LuaValue<'lua> {
|
||||
fn lua_to_dom_value(
|
||||
&self,
|
||||
lua: &'lua Lua,
|
||||
variant_type: RbxVariantType,
|
||||
) -> DatatypeConversionResult<RbxVariant> {
|
||||
variant_type: DomType,
|
||||
) -> DomConversionResult<DomValue> {
|
||||
use base64::engine::general_purpose::STANDARD_NO_PAD;
|
||||
use base64::engine::Engine as _;
|
||||
|
||||
use rbx_dom_weak::types as rbx;
|
||||
use RbxVariant as Rbx;
|
||||
use RbxVariantType as RbxType;
|
||||
use rbx_dom_weak::types as dom;
|
||||
|
||||
match (self, variant_type) {
|
||||
(LuaValue::Boolean(b), RbxType::Bool) => Ok(Rbx::Bool(*b)),
|
||||
(LuaValue::Boolean(b), DomType::Bool) => Ok(DomValue::Bool(*b)),
|
||||
|
||||
(LuaValue::Integer(i), RbxType::Int64) => Ok(Rbx::Int64(*i as i64)),
|
||||
(LuaValue::Integer(i), RbxType::Int32) => Ok(Rbx::Int32(*i)),
|
||||
(LuaValue::Integer(i), RbxType::Float64) => Ok(Rbx::Float64(*i as f64)),
|
||||
(LuaValue::Integer(i), RbxType::Float32) => Ok(Rbx::Float32(*i as f32)),
|
||||
(LuaValue::Integer(i), DomType::Int64) => Ok(DomValue::Int64(*i as i64)),
|
||||
(LuaValue::Integer(i), DomType::Int32) => Ok(DomValue::Int32(*i)),
|
||||
(LuaValue::Integer(i), DomType::Float64) => Ok(DomValue::Float64(*i as f64)),
|
||||
(LuaValue::Integer(i), DomType::Float32) => Ok(DomValue::Float32(*i as f32)),
|
||||
|
||||
(LuaValue::Number(n), RbxType::Int64) => Ok(Rbx::Int64(*n as i64)),
|
||||
(LuaValue::Number(n), RbxType::Int32) => Ok(Rbx::Int32(*n as i32)),
|
||||
(LuaValue::Number(n), RbxType::Float64) => Ok(Rbx::Float64(*n)),
|
||||
(LuaValue::Number(n), RbxType::Float32) => Ok(Rbx::Float32(*n as f32)),
|
||||
(LuaValue::Number(n), DomType::Int64) => Ok(DomValue::Int64(*n as i64)),
|
||||
(LuaValue::Number(n), DomType::Int32) => Ok(DomValue::Int32(*n as i32)),
|
||||
(LuaValue::Number(n), DomType::Float64) => Ok(DomValue::Float64(*n)),
|
||||
(LuaValue::Number(n), DomType::Float32) => Ok(DomValue::Float32(*n as f32)),
|
||||
|
||||
(LuaValue::String(s), RbxType::String) => Ok(Rbx::String(s.to_str()?.to_string())),
|
||||
(LuaValue::String(s), RbxType::Content) => {
|
||||
Ok(Rbx::Content(s.to_str()?.to_string().into()))
|
||||
(LuaValue::String(s), DomType::String) => Ok(DomValue::String(s.to_str()?.to_string())),
|
||||
(LuaValue::String(s), DomType::Content) => {
|
||||
Ok(DomValue::Content(s.to_str()?.to_string().into()))
|
||||
}
|
||||
(LuaValue::String(s), RbxType::BinaryString) => {
|
||||
Ok(Rbx::BinaryString(STANDARD_NO_PAD.decode(s)?.into()))
|
||||
(LuaValue::String(s), DomType::BinaryString) => {
|
||||
Ok(DomValue::BinaryString(STANDARD_NO_PAD.decode(s)?.into()))
|
||||
}
|
||||
|
||||
// NOTE: We need this special case here to handle default (nil)
|
||||
// physical properties since our PhysicalProperties datatype
|
||||
// implementation does not handle default at all, only custom
|
||||
(LuaValue::Nil, RbxType::PhysicalProperties) => {
|
||||
Ok(Rbx::PhysicalProperties(rbx::PhysicalProperties::Default))
|
||||
}
|
||||
(LuaValue::Nil, DomType::PhysicalProperties) => Ok(DomValue::PhysicalProperties(
|
||||
dom::PhysicalProperties::Default,
|
||||
)),
|
||||
|
||||
(LuaValue::UserData(u), d) => u.lua_to_rbx_variant(lua, d),
|
||||
(LuaValue::UserData(u), d) => u.lua_to_dom_value(lua, d),
|
||||
|
||||
(v, d) => Err(DatatypeConversionError::ToRbxVariant {
|
||||
(v, d) => Err(DomConversionError::ToDomValue {
|
||||
to: d.variant_name(),
|
||||
from: v.type_name(),
|
||||
detail: None,
|
||||
|
@ -126,13 +123,12 @@ impl<'lua> LuaToRbxVariant<'lua> for LuaValue<'lua> {
|
|||
|
||||
*/
|
||||
|
||||
impl<'lua> RbxVariantToLua<'lua> for LuaAnyUserData<'lua> {
|
||||
impl<'lua> DomValueToLua<'lua> for LuaAnyUserData<'lua> {
|
||||
#[rustfmt::skip]
|
||||
fn rbx_variant_to_lua(lua: &'lua Lua, variant: &RbxVariant) -> DatatypeConversionResult<Self> {
|
||||
fn dom_value_to_lua(lua: &'lua Lua, variant: &DomValue) -> DomConversionResult<Self> {
|
||||
use super::types::*;
|
||||
|
||||
use rbx_dom_weak::types as rbx;
|
||||
use RbxVariant as Rbx;
|
||||
use rbx_dom_weak::types as dom;
|
||||
|
||||
/*
|
||||
NOTES:
|
||||
|
@ -147,45 +143,45 @@ impl<'lua> RbxVariantToLua<'lua> for LuaAnyUserData<'lua> {
|
|||
|
||||
*/
|
||||
Ok(match variant.clone() {
|
||||
Rbx::Axes(value) => lua.create_userdata(Axes::from(value))?,
|
||||
Rbx::Faces(value) => lua.create_userdata(Faces::from(value))?,
|
||||
DomValue::Axes(value) => lua.create_userdata(Axes::from(value))?,
|
||||
DomValue::Faces(value) => lua.create_userdata(Faces::from(value))?,
|
||||
|
||||
Rbx::CFrame(value) => lua.create_userdata(CFrame::from(value))?,
|
||||
DomValue::CFrame(value) => lua.create_userdata(CFrame::from(value))?,
|
||||
|
||||
Rbx::BrickColor(value) => lua.create_userdata(BrickColor::from(value))?,
|
||||
Rbx::Color3(value) => lua.create_userdata(Color3::from(value))?,
|
||||
Rbx::Color3uint8(value) => lua.create_userdata(Color3::from(value))?,
|
||||
Rbx::ColorSequence(value) => lua.create_userdata(ColorSequence::from(value))?,
|
||||
DomValue::BrickColor(value) => lua.create_userdata(BrickColor::from(value))?,
|
||||
DomValue::Color3(value) => lua.create_userdata(Color3::from(value))?,
|
||||
DomValue::Color3uint8(value) => lua.create_userdata(Color3::from(value))?,
|
||||
DomValue::ColorSequence(value) => lua.create_userdata(ColorSequence::from(value))?,
|
||||
|
||||
Rbx::Font(value) => lua.create_userdata(Font::from(value))?,
|
||||
DomValue::Font(value) => lua.create_userdata(Font::from(value))?,
|
||||
|
||||
Rbx::NumberRange(value) => lua.create_userdata(NumberRange::from(value))?,
|
||||
Rbx::NumberSequence(value) => lua.create_userdata(NumberSequence::from(value))?,
|
||||
DomValue::NumberRange(value) => lua.create_userdata(NumberRange::from(value))?,
|
||||
DomValue::NumberSequence(value) => lua.create_userdata(NumberSequence::from(value))?,
|
||||
|
||||
Rbx::Ray(value) => lua.create_userdata(Ray::from(value))?,
|
||||
DomValue::Ray(value) => lua.create_userdata(Ray::from(value))?,
|
||||
|
||||
Rbx::Rect(value) => lua.create_userdata(Rect::from(value))?,
|
||||
Rbx::UDim(value) => lua.create_userdata(UDim::from(value))?,
|
||||
Rbx::UDim2(value) => lua.create_userdata(UDim2::from(value))?,
|
||||
DomValue::Rect(value) => lua.create_userdata(Rect::from(value))?,
|
||||
DomValue::UDim(value) => lua.create_userdata(UDim::from(value))?,
|
||||
DomValue::UDim2(value) => lua.create_userdata(UDim2::from(value))?,
|
||||
|
||||
Rbx::Region3(value) => lua.create_userdata(Region3::from(value))?,
|
||||
Rbx::Region3int16(value) => lua.create_userdata(Region3int16::from(value))?,
|
||||
Rbx::Vector2(value) => lua.create_userdata(Vector2::from(value))?,
|
||||
Rbx::Vector2int16(value) => lua.create_userdata(Vector2int16::from(value))?,
|
||||
Rbx::Vector3(value) => lua.create_userdata(Vector3::from(value))?,
|
||||
Rbx::Vector3int16(value) => lua.create_userdata(Vector3int16::from(value))?,
|
||||
DomValue::Region3(value) => lua.create_userdata(Region3::from(value))?,
|
||||
DomValue::Region3int16(value) => lua.create_userdata(Region3int16::from(value))?,
|
||||
DomValue::Vector2(value) => lua.create_userdata(Vector2::from(value))?,
|
||||
DomValue::Vector2int16(value) => lua.create_userdata(Vector2int16::from(value))?,
|
||||
DomValue::Vector3(value) => lua.create_userdata(Vector3::from(value))?,
|
||||
DomValue::Vector3int16(value) => lua.create_userdata(Vector3int16::from(value))?,
|
||||
|
||||
Rbx::OptionalCFrame(value) => match value {
|
||||
DomValue::OptionalCFrame(value) => match value {
|
||||
Some(value) => lua.create_userdata(CFrame::from(value))?,
|
||||
None => lua.create_userdata(CFrame::IDENTITY)?
|
||||
},
|
||||
|
||||
Rbx::PhysicalProperties(rbx::PhysicalProperties::Custom(value)) => {
|
||||
DomValue::PhysicalProperties(dom::PhysicalProperties::Custom(value)) => {
|
||||
lua.create_userdata(PhysicalProperties::from(value))?
|
||||
},
|
||||
|
||||
v => {
|
||||
return Err(DatatypeConversionError::FromRbxVariant {
|
||||
return Err(DomConversionError::FromDomValue {
|
||||
from: v.variant_name(),
|
||||
to: "userdata",
|
||||
detail: Some("Type not supported".to_string()),
|
||||
|
@ -195,63 +191,63 @@ impl<'lua> RbxVariantToLua<'lua> for LuaAnyUserData<'lua> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'lua> LuaToRbxVariant<'lua> for LuaAnyUserData<'lua> {
|
||||
impl<'lua> LuaToDomValue<'lua> for LuaAnyUserData<'lua> {
|
||||
#[rustfmt::skip]
|
||||
fn lua_to_rbx_variant(
|
||||
fn lua_to_dom_value(
|
||||
&self,
|
||||
_: &'lua Lua,
|
||||
variant_type: RbxVariantType,
|
||||
) -> DatatypeConversionResult<RbxVariant> {
|
||||
variant_type: DomType,
|
||||
) -> DomConversionResult<DomValue> {
|
||||
use super::types::*;
|
||||
|
||||
use rbx_dom_weak::types as rbx;
|
||||
use rbx_dom_weak::types as dom;
|
||||
|
||||
let f = match variant_type {
|
||||
RbxVariantType::Axes => convert::<Axes, rbx::Axes>,
|
||||
RbxVariantType::Faces => convert::<Faces, rbx::Faces>,
|
||||
DomType::Axes => convert::<Axes, dom::Axes>,
|
||||
DomType::Faces => convert::<Faces, dom::Faces>,
|
||||
|
||||
RbxVariantType::CFrame => convert::<CFrame, rbx::CFrame>,
|
||||
DomType::CFrame => convert::<CFrame, dom::CFrame>,
|
||||
|
||||
RbxVariantType::BrickColor => convert::<BrickColor, rbx::BrickColor>,
|
||||
RbxVariantType::Color3 => convert::<Color3, rbx::Color3>,
|
||||
RbxVariantType::Color3uint8 => convert::<Color3, rbx::Color3uint8>,
|
||||
RbxVariantType::ColorSequence => convert::<ColorSequence, rbx::ColorSequence>,
|
||||
DomType::BrickColor => convert::<BrickColor, dom::BrickColor>,
|
||||
DomType::Color3 => convert::<Color3, dom::Color3>,
|
||||
DomType::Color3uint8 => convert::<Color3, dom::Color3uint8>,
|
||||
DomType::ColorSequence => convert::<ColorSequence, dom::ColorSequence>,
|
||||
|
||||
RbxVariantType::Enum => convert::<EnumItem, rbx::Enum>,
|
||||
DomType::Enum => convert::<EnumItem, dom::Enum>,
|
||||
|
||||
RbxVariantType::Font => convert::<Font, rbx::Font>,
|
||||
DomType::Font => convert::<Font, dom::Font>,
|
||||
|
||||
RbxVariantType::NumberRange => convert::<NumberRange, rbx::NumberRange>,
|
||||
RbxVariantType::NumberSequence => convert::<NumberSequence, rbx::NumberSequence>,
|
||||
DomType::NumberRange => convert::<NumberRange, dom::NumberRange>,
|
||||
DomType::NumberSequence => convert::<NumberSequence, dom::NumberSequence>,
|
||||
|
||||
RbxVariantType::Rect => convert::<Rect, rbx::Rect>,
|
||||
RbxVariantType::UDim => convert::<UDim, rbx::UDim>,
|
||||
RbxVariantType::UDim2 => convert::<UDim2, rbx::UDim2>,
|
||||
DomType::Rect => convert::<Rect, dom::Rect>,
|
||||
DomType::UDim => convert::<UDim, dom::UDim>,
|
||||
DomType::UDim2 => convert::<UDim2, dom::UDim2>,
|
||||
|
||||
RbxVariantType::Ray => convert::<Ray, rbx::Ray>,
|
||||
DomType::Ray => convert::<Ray, dom::Ray>,
|
||||
|
||||
RbxVariantType::Region3 => convert::<Region3, rbx::Region3>,
|
||||
RbxVariantType::Region3int16 => convert::<Region3int16, rbx::Region3int16>,
|
||||
RbxVariantType::Vector2 => convert::<Vector2, rbx::Vector2>,
|
||||
RbxVariantType::Vector2int16 => convert::<Vector2int16, rbx::Vector2int16>,
|
||||
RbxVariantType::Vector3 => convert::<Vector3, rbx::Vector3>,
|
||||
RbxVariantType::Vector3int16 => convert::<Vector3int16, rbx::Vector3int16>,
|
||||
DomType::Region3 => convert::<Region3, dom::Region3>,
|
||||
DomType::Region3int16 => convert::<Region3int16, dom::Region3int16>,
|
||||
DomType::Vector2 => convert::<Vector2, dom::Vector2>,
|
||||
DomType::Vector2int16 => convert::<Vector2int16, dom::Vector2int16>,
|
||||
DomType::Vector3 => convert::<Vector3, dom::Vector3>,
|
||||
DomType::Vector3int16 => convert::<Vector3int16, dom::Vector3int16>,
|
||||
|
||||
RbxVariantType::OptionalCFrame => return match self.borrow::<CFrame>() {
|
||||
Ok(value) => Ok(RbxVariant::OptionalCFrame(Some(rbx::CFrame::from(*value)))),
|
||||
DomType::OptionalCFrame => return match self.borrow::<CFrame>() {
|
||||
Ok(value) => Ok(DomValue::OptionalCFrame(Some(dom::CFrame::from(*value)))),
|
||||
Err(e) => Err(lua_userdata_error_to_conversion_error(variant_type, e)),
|
||||
},
|
||||
|
||||
RbxVariantType::PhysicalProperties => return match self.borrow::<PhysicalProperties>() {
|
||||
DomType::PhysicalProperties => return match self.borrow::<PhysicalProperties>() {
|
||||
Ok(value) => {
|
||||
let props = rbx::CustomPhysicalProperties::from(*value);
|
||||
let custom = rbx::PhysicalProperties::Custom(props);
|
||||
Ok(RbxVariant::PhysicalProperties(custom))
|
||||
let props = dom::CustomPhysicalProperties::from(*value);
|
||||
let custom = dom::PhysicalProperties::Custom(props);
|
||||
Ok(DomValue::PhysicalProperties(custom))
|
||||
},
|
||||
Err(e) => Err(lua_userdata_error_to_conversion_error(variant_type, e)),
|
||||
},
|
||||
|
||||
_ => return Err(DatatypeConversionError::ToRbxVariant {
|
||||
_ => return Err(DomConversionError::ToDomValue {
|
||||
to: variant_type.variant_name(),
|
||||
from: "userdata",
|
||||
detail: Some("Type not supported".to_string()),
|
||||
|
@ -262,31 +258,31 @@ impl<'lua> LuaToRbxVariant<'lua> for LuaAnyUserData<'lua> {
|
|||
}
|
||||
}
|
||||
|
||||
fn convert<Datatype, RbxType>(
|
||||
fn convert<TypeFrom, TypeTo>(
|
||||
userdata: &LuaAnyUserData,
|
||||
variant_type: RbxVariantType,
|
||||
) -> DatatypeConversionResult<RbxVariant>
|
||||
variant_type: DomType,
|
||||
) -> DomConversionResult<DomValue>
|
||||
where
|
||||
Datatype: LuaUserData + Clone + 'static,
|
||||
RbxType: From<Datatype> + Into<RbxVariant>,
|
||||
TypeFrom: LuaUserData + Clone + 'static,
|
||||
TypeTo: From<TypeFrom> + Into<DomValue>,
|
||||
{
|
||||
match userdata.borrow::<Datatype>() {
|
||||
Ok(value) => Ok(RbxType::from(value.clone()).into()),
|
||||
match userdata.borrow::<TypeFrom>() {
|
||||
Ok(value) => Ok(TypeTo::from(value.clone()).into()),
|
||||
Err(e) => Err(lua_userdata_error_to_conversion_error(variant_type, e)),
|
||||
}
|
||||
}
|
||||
|
||||
fn lua_userdata_error_to_conversion_error(
|
||||
variant_type: RbxVariantType,
|
||||
variant_type: DomType,
|
||||
error: LuaError,
|
||||
) -> DatatypeConversionError {
|
||||
) -> DomConversionError {
|
||||
match error {
|
||||
LuaError::UserDataTypeMismatch => DatatypeConversionError::ToRbxVariant {
|
||||
LuaError::UserDataTypeMismatch => DomConversionError::ToDomValue {
|
||||
to: variant_type.variant_name(),
|
||||
from: "userdata",
|
||||
detail: Some("Type mismatch".to_string()),
|
||||
},
|
||||
e => DatatypeConversionError::ToRbxVariant {
|
||||
e => DomConversionError::ToDomValue {
|
||||
to: variant_type.variant_name(),
|
||||
from: "userdata",
|
||||
detail: Some(format!("Internal error: {e}")),
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use super::*;
|
||||
|
||||
pub(super) trait RbxVariantExt {
|
||||
pub(super) trait DomValueExt {
|
||||
fn variant_name(&self) -> &'static str;
|
||||
}
|
||||
|
||||
impl RbxVariantExt for RbxVariantType {
|
||||
impl DomValueExt for DomType {
|
||||
fn variant_name(&self) -> &'static str {
|
||||
use RbxVariantType::*;
|
||||
use DomType::*;
|
||||
match self {
|
||||
Axes => "Axes",
|
||||
BinaryString => "BinaryString",
|
||||
|
@ -45,7 +45,7 @@ impl RbxVariantExt for RbxVariantType {
|
|||
}
|
||||
}
|
||||
|
||||
impl RbxVariantExt for RbxVariant {
|
||||
impl DomValueExt for DomValue {
|
||||
fn variant_name(&self) -> &'static str {
|
||||
self.ty().variant_name()
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
pub(crate) use rbx_dom_weak::types::{Variant as RbxVariant, VariantType as RbxVariantType};
|
||||
pub(crate) use rbx_dom_weak::types::{Variant as DomValue, VariantType as DomType};
|
||||
|
||||
mod conversion;
|
||||
mod extension;
|
||||
|
|
|
@ -7,24 +7,24 @@ use mlua::Error as LuaError;
|
|||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) enum DatatypeConversionError {
|
||||
pub(crate) enum DomConversionError {
|
||||
LuaError(LuaError),
|
||||
External {
|
||||
message: String,
|
||||
},
|
||||
FromRbxVariant {
|
||||
FromDomValue {
|
||||
from: &'static str,
|
||||
to: &'static str,
|
||||
detail: Option<String>,
|
||||
},
|
||||
ToRbxVariant {
|
||||
ToDomValue {
|
||||
to: &'static str,
|
||||
from: &'static str,
|
||||
detail: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
impl fmt::Display for DatatypeConversionError {
|
||||
impl fmt::Display for DomConversionError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
|
@ -32,8 +32,7 @@ impl fmt::Display for DatatypeConversionError {
|
|||
match self {
|
||||
Self::LuaError(error) => error.to_string(),
|
||||
Self::External { message } => message.to_string(),
|
||||
Self::FromRbxVariant { from, to, detail }
|
||||
| Self::ToRbxVariant { from, to, detail } => {
|
||||
Self::FromDomValue { from, to, detail } | Self::ToDomValue { from, to, detail } => {
|
||||
match detail {
|
||||
Some(d) => format!("Failed to convert from '{from}' into '{to}' - {d}"),
|
||||
None => format!("Failed to convert from '{from}' into '{to}'",),
|
||||
|
@ -44,28 +43,28 @@ impl fmt::Display for DatatypeConversionError {
|
|||
}
|
||||
}
|
||||
|
||||
impl Error for DatatypeConversionError {}
|
||||
impl Error for DomConversionError {}
|
||||
|
||||
impl From<LuaError> for DatatypeConversionError {
|
||||
impl From<LuaError> for DomConversionError {
|
||||
fn from(value: LuaError) -> Self {
|
||||
Self::LuaError(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<IoError> for DatatypeConversionError {
|
||||
impl From<IoError> for DomConversionError {
|
||||
fn from(value: IoError) -> Self {
|
||||
DatatypeConversionError::External {
|
||||
DomConversionError::External {
|
||||
message: value.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<base64::DecodeError> for DatatypeConversionError {
|
||||
impl From<base64::DecodeError> for DomConversionError {
|
||||
fn from(value: base64::DecodeError) -> Self {
|
||||
DatatypeConversionError::External {
|
||||
DomConversionError::External {
|
||||
message: value.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) type DatatypeConversionResult<T> = Result<T, DatatypeConversionError>;
|
||||
pub(crate) type DomConversionResult<T> = Result<T, DomConversionError>;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use core::fmt;
|
||||
|
||||
use mlua::prelude::*;
|
||||
use rbx_dom_weak::types::Axes as RbxAxes;
|
||||
use rbx_dom_weak::types::Axes as DomAxes;
|
||||
|
||||
use super::{super::*, EnumItem};
|
||||
|
||||
|
@ -96,8 +96,8 @@ impl fmt::Display for Axes {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RbxAxes> for Axes {
|
||||
fn from(v: RbxAxes) -> Self {
|
||||
impl From<DomAxes> for Axes {
|
||||
fn from(v: DomAxes) -> Self {
|
||||
let bits = v.bits();
|
||||
Self {
|
||||
x: (bits & 1) == 1,
|
||||
|
@ -107,12 +107,12 @@ impl From<RbxAxes> for Axes {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Axes> for RbxAxes {
|
||||
impl From<Axes> for DomAxes {
|
||||
fn from(v: Axes) -> Self {
|
||||
let mut bits = 0;
|
||||
bits += v.x as u8;
|
||||
bits += (v.y as u8) << 1;
|
||||
bits += (v.z as u8) << 2;
|
||||
RbxAxes::from_bits(bits).expect("Invalid bits")
|
||||
DomAxes::from_bits(bits).expect("Invalid bits")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ use core::fmt;
|
|||
|
||||
use mlua::prelude::*;
|
||||
use rand::seq::SliceRandom;
|
||||
use rbx_dom_weak::types::BrickColor as RbxBrickColor;
|
||||
use rbx_dom_weak::types::BrickColor as DomBrickColor;
|
||||
|
||||
use super::{super::*, Color3};
|
||||
|
||||
|
@ -13,7 +13,7 @@ use super::{super::*, Color3};
|
|||
*/
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub struct BrickColor {
|
||||
// Unfortunately we can't use RbxBrickColor as the backing type here
|
||||
// Unfortunately we can't use DomBrickColor as the backing type here
|
||||
// because it does not expose any way of getting the actual rgb colors :-(
|
||||
pub(crate) number: u16,
|
||||
pub(crate) name: &'static str,
|
||||
|
@ -124,15 +124,15 @@ impl From<BrickColor> for Color3 {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RbxBrickColor> for BrickColor {
|
||||
fn from(v: RbxBrickColor) -> Self {
|
||||
impl From<DomBrickColor> for BrickColor {
|
||||
fn from(v: DomBrickColor) -> Self {
|
||||
color_from_name(v.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<BrickColor> for RbxBrickColor {
|
||||
impl From<BrickColor> for DomBrickColor {
|
||||
fn from(v: BrickColor) -> Self {
|
||||
RbxBrickColor::from_number(v.number).unwrap_or(RbxBrickColor::MediumStoneGrey)
|
||||
DomBrickColor::from_number(v.number).unwrap_or(DomBrickColor::MediumStoneGrey)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::ops;
|
|||
|
||||
use glam::{EulerRot, Mat4, Quat, Vec3};
|
||||
use mlua::prelude::*;
|
||||
use rbx_dom_weak::types::{CFrame as RbxCFrame, Matrix3 as RbxMatrix3, Vector3 as RbxVector3};
|
||||
use rbx_dom_weak::types::{CFrame as DomCFrame, Matrix3 as DomMatrix3, Vector3 as DomVector3};
|
||||
|
||||
use super::{super::*, Vector3};
|
||||
|
||||
|
@ -305,8 +305,8 @@ impl ops::Sub<Vector3> for CFrame {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RbxCFrame> for CFrame {
|
||||
fn from(v: RbxCFrame) -> Self {
|
||||
impl From<DomCFrame> for CFrame {
|
||||
fn from(v: DomCFrame) -> Self {
|
||||
CFrame(Mat4::from_cols(
|
||||
Vector3::from(v.orientation.x).0.extend(0.0),
|
||||
Vector3::from(v.orientation.y).0.extend(0.0),
|
||||
|
@ -316,15 +316,15 @@ impl From<RbxCFrame> for CFrame {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<CFrame> for RbxCFrame {
|
||||
impl From<CFrame> for DomCFrame {
|
||||
fn from(v: CFrame) -> Self {
|
||||
let (rx, ry, rz) = v.orientation();
|
||||
RbxCFrame {
|
||||
position: RbxVector3::from(Vector3(v.position())),
|
||||
orientation: RbxMatrix3::new(
|
||||
RbxVector3::from(Vector3(rx)),
|
||||
RbxVector3::from(Vector3(ry)),
|
||||
RbxVector3::from(Vector3(rz)),
|
||||
DomCFrame {
|
||||
position: DomVector3::from(Vector3(v.position())),
|
||||
orientation: DomMatrix3::new(
|
||||
DomVector3::from(Vector3(rx)),
|
||||
DomVector3::from(Vector3(ry)),
|
||||
DomVector3::from(Vector3(rz)),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::ops;
|
|||
|
||||
use glam::Vec3;
|
||||
use mlua::prelude::*;
|
||||
use rbx_dom_weak::types::{Color3 as RbxColor3, Color3uint8 as RbxColor3uint8};
|
||||
use rbx_dom_weak::types::{Color3 as DomColor3, Color3uint8 as DomColor3uint8};
|
||||
|
||||
use super::super::*;
|
||||
|
||||
|
@ -261,8 +261,8 @@ impl ops::Div<f32> for Color3 {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RbxColor3> for Color3 {
|
||||
fn from(v: RbxColor3) -> Self {
|
||||
impl From<DomColor3> for Color3 {
|
||||
fn from(v: DomColor3) -> Self {
|
||||
Self {
|
||||
r: v.r,
|
||||
g: v.g,
|
||||
|
@ -271,7 +271,7 @@ impl From<RbxColor3> for Color3 {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Color3> for RbxColor3 {
|
||||
impl From<Color3> for DomColor3 {
|
||||
fn from(v: Color3) -> Self {
|
||||
Self {
|
||||
r: v.r,
|
||||
|
@ -281,8 +281,8 @@ impl From<Color3> for RbxColor3 {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RbxColor3uint8> for Color3 {
|
||||
fn from(v: RbxColor3uint8) -> Self {
|
||||
impl From<DomColor3uint8> for Color3 {
|
||||
fn from(v: DomColor3uint8) -> Self {
|
||||
Self {
|
||||
r: (v.r as f32) / 255f32,
|
||||
g: (v.g as f32) / 255f32,
|
||||
|
@ -291,7 +291,7 @@ impl From<RbxColor3uint8> for Color3 {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Color3> for RbxColor3uint8 {
|
||||
impl From<Color3> for DomColor3uint8 {
|
||||
fn from(v: Color3) -> Self {
|
||||
Self {
|
||||
r: v.r.clamp(u8::MIN as f32, u8::MAX as f32) as u8,
|
||||
|
|
|
@ -2,7 +2,7 @@ use core::fmt;
|
|||
|
||||
use mlua::prelude::*;
|
||||
use rbx_dom_weak::types::{
|
||||
ColorSequence as RbxColorSequence, ColorSequenceKeypoint as RbxColorSequenceKeypoint,
|
||||
ColorSequence as DomColorSequence, ColorSequenceKeypoint as DomColorSequenceKeypoint,
|
||||
};
|
||||
|
||||
use super::{super::*, Color3, ColorSequenceKeypoint};
|
||||
|
@ -82,8 +82,8 @@ impl fmt::Display for ColorSequence {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RbxColorSequence> for ColorSequence {
|
||||
fn from(v: RbxColorSequence) -> Self {
|
||||
impl From<DomColorSequence> for ColorSequence {
|
||||
fn from(v: DomColorSequence) -> Self {
|
||||
Self {
|
||||
keypoints: v
|
||||
.keypoints
|
||||
|
@ -95,14 +95,14 @@ impl From<RbxColorSequence> for ColorSequence {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<ColorSequence> for RbxColorSequence {
|
||||
impl From<ColorSequence> for DomColorSequence {
|
||||
fn from(v: ColorSequence) -> Self {
|
||||
Self {
|
||||
keypoints: v
|
||||
.keypoints
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(RbxColorSequenceKeypoint::from)
|
||||
.map(DomColorSequenceKeypoint::from)
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use core::fmt;
|
||||
|
||||
use mlua::prelude::*;
|
||||
use rbx_dom_weak::types::ColorSequenceKeypoint as RbxColorSequenceKeypoint;
|
||||
use rbx_dom_weak::types::ColorSequenceKeypoint as DomColorSequenceKeypoint;
|
||||
|
||||
use super::{super::*, Color3};
|
||||
|
||||
|
@ -46,8 +46,8 @@ impl fmt::Display for ColorSequenceKeypoint {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RbxColorSequenceKeypoint> for ColorSequenceKeypoint {
|
||||
fn from(v: RbxColorSequenceKeypoint) -> Self {
|
||||
impl From<DomColorSequenceKeypoint> for ColorSequenceKeypoint {
|
||||
fn from(v: DomColorSequenceKeypoint) -> Self {
|
||||
Self {
|
||||
time: v.time,
|
||||
color: v.color.into(),
|
||||
|
@ -55,7 +55,7 @@ impl From<RbxColorSequenceKeypoint> for ColorSequenceKeypoint {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<ColorSequenceKeypoint> for RbxColorSequenceKeypoint {
|
||||
impl From<ColorSequenceKeypoint> for DomColorSequenceKeypoint {
|
||||
fn from(v: ColorSequenceKeypoint) -> Self {
|
||||
Self {
|
||||
time: v.time,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use core::fmt;
|
||||
|
||||
use mlua::prelude::*;
|
||||
use rbx_dom_weak::types::Enum as RbxEnum;
|
||||
use rbx_reflection::DataType as RbxDataType;
|
||||
use rbx_dom_weak::types::Enum as DomEnum;
|
||||
use rbx_reflection::DataType as DomDataType;
|
||||
|
||||
use super::{super::*, Enum};
|
||||
|
||||
|
@ -64,7 +64,7 @@ impl EnumItem {
|
|||
.properties
|
||||
.get(prop_name.as_ref())?;
|
||||
let prop_enum = match &prop.data_type {
|
||||
RbxDataType::Enum(name) => db.enums.get(name.as_ref()),
|
||||
DomDataType::Enum(name) => db.enums.get(name.as_ref()),
|
||||
_ => None,
|
||||
}?;
|
||||
let enum_name = prop_enum.items.iter().find_map(|(name, v)| {
|
||||
|
@ -107,8 +107,8 @@ impl PartialEq for EnumItem {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<EnumItem> for RbxEnum {
|
||||
impl From<EnumItem> for DomEnum {
|
||||
fn from(v: EnumItem) -> Self {
|
||||
RbxEnum::from_u32(v.value)
|
||||
DomEnum::from_u32(v.value)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use core::fmt;
|
||||
|
||||
use mlua::prelude::*;
|
||||
use rbx_dom_weak::types::Faces as RbxFaces;
|
||||
use rbx_dom_weak::types::Faces as DomFaces;
|
||||
|
||||
use super::{super::*, EnumItem};
|
||||
|
||||
|
@ -105,8 +105,8 @@ impl fmt::Display for Faces {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RbxFaces> for Faces {
|
||||
fn from(v: RbxFaces) -> Self {
|
||||
impl From<DomFaces> for Faces {
|
||||
fn from(v: DomFaces) -> Self {
|
||||
let bits = v.bits();
|
||||
Self {
|
||||
right: (bits & 1) == 1,
|
||||
|
@ -119,7 +119,7 @@ impl From<RbxFaces> for Faces {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Faces> for RbxFaces {
|
||||
impl From<Faces> for DomFaces {
|
||||
fn from(v: Faces) -> Self {
|
||||
let mut bits = 0;
|
||||
bits += v.right as u8;
|
||||
|
@ -128,6 +128,6 @@ impl From<Faces> for RbxFaces {
|
|||
bits += (v.left as u8) << 3;
|
||||
bits += (v.bottom as u8) << 4;
|
||||
bits += (v.front as u8) << 5;
|
||||
RbxFaces::from_bits(bits).expect("Invalid bits")
|
||||
DomFaces::from_bits(bits).expect("Invalid bits")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::str::FromStr;
|
|||
|
||||
use mlua::prelude::*;
|
||||
use rbx_dom_weak::types::{
|
||||
Font as RbxFont, FontStyle as RbxFontStyle, FontWeight as RbxFontWeight,
|
||||
Font as DomFont, FontStyle as DomFontStyle, FontWeight as DomFontWeight,
|
||||
};
|
||||
|
||||
use super::{super::*, EnumItem};
|
||||
|
@ -135,8 +135,8 @@ impl fmt::Display for Font {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RbxFont> for Font {
|
||||
fn from(v: RbxFont) -> Self {
|
||||
impl From<DomFont> for Font {
|
||||
fn from(v: DomFont) -> Self {
|
||||
Self {
|
||||
family: v.family,
|
||||
weight: v.weight.into(),
|
||||
|
@ -146,9 +146,9 @@ impl From<RbxFont> for Font {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Font> for RbxFont {
|
||||
impl From<Font> for DomFont {
|
||||
fn from(v: Font) -> Self {
|
||||
RbxFont {
|
||||
DomFont {
|
||||
family: v.family,
|
||||
weight: v.weight.into(),
|
||||
style: v.style.into(),
|
||||
|
@ -157,27 +157,27 @@ impl From<Font> for RbxFont {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RbxFontWeight> for FontWeight {
|
||||
fn from(v: RbxFontWeight) -> Self {
|
||||
impl From<DomFontWeight> for FontWeight {
|
||||
fn from(v: DomFontWeight) -> Self {
|
||||
FontWeight::from_u16(v.as_u16()).expect("Missing font weight")
|
||||
}
|
||||
}
|
||||
|
||||
impl From<FontWeight> for RbxFontWeight {
|
||||
impl From<FontWeight> for DomFontWeight {
|
||||
fn from(v: FontWeight) -> Self {
|
||||
RbxFontWeight::from_u16(v.as_u16()).expect("Missing rbx font weight")
|
||||
DomFontWeight::from_u16(v.as_u16()).expect("Missing rbx font weight")
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RbxFontStyle> for FontStyle {
|
||||
fn from(v: RbxFontStyle) -> Self {
|
||||
impl From<DomFontStyle> for FontStyle {
|
||||
fn from(v: DomFontStyle) -> Self {
|
||||
FontStyle::from_u8(v.as_u8()).expect("Missing font weight")
|
||||
}
|
||||
}
|
||||
|
||||
impl From<FontStyle> for RbxFontStyle {
|
||||
impl From<FontStyle> for DomFontStyle {
|
||||
fn from(v: FontStyle) -> Self {
|
||||
RbxFontStyle::from_u8(v.as_u8()).expect("Missing rbx font weight")
|
||||
DomFontStyle::from_u8(v.as_u8()).expect("Missing rbx font weight")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use core::fmt;
|
||||
|
||||
use mlua::prelude::*;
|
||||
use rbx_dom_weak::types::NumberRange as RbxNumberRange;
|
||||
use rbx_dom_weak::types::NumberRange as DomNumberRange;
|
||||
|
||||
use super::super::*;
|
||||
|
||||
|
@ -51,8 +51,8 @@ impl fmt::Display for NumberRange {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RbxNumberRange> for NumberRange {
|
||||
fn from(v: RbxNumberRange) -> Self {
|
||||
impl From<DomNumberRange> for NumberRange {
|
||||
fn from(v: DomNumberRange) -> Self {
|
||||
Self {
|
||||
min: v.min,
|
||||
max: v.max,
|
||||
|
@ -60,7 +60,7 @@ impl From<RbxNumberRange> for NumberRange {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<NumberRange> for RbxNumberRange {
|
||||
impl From<NumberRange> for DomNumberRange {
|
||||
fn from(v: NumberRange) -> Self {
|
||||
Self {
|
||||
min: v.min,
|
||||
|
|
|
@ -2,7 +2,7 @@ use core::fmt;
|
|||
|
||||
use mlua::prelude::*;
|
||||
use rbx_dom_weak::types::{
|
||||
NumberSequence as RbxNumberSequence, NumberSequenceKeypoint as RbxNumberSequenceKeypoint,
|
||||
NumberSequence as DomNumberSequence, NumberSequenceKeypoint as DomNumberSequenceKeypoint,
|
||||
};
|
||||
|
||||
use super::{super::*, NumberSequenceKeypoint};
|
||||
|
@ -92,8 +92,8 @@ impl fmt::Display for NumberSequence {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RbxNumberSequence> for NumberSequence {
|
||||
fn from(v: RbxNumberSequence) -> Self {
|
||||
impl From<DomNumberSequence> for NumberSequence {
|
||||
fn from(v: DomNumberSequence) -> Self {
|
||||
Self {
|
||||
keypoints: v
|
||||
.keypoints
|
||||
|
@ -105,14 +105,14 @@ impl From<RbxNumberSequence> for NumberSequence {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<NumberSequence> for RbxNumberSequence {
|
||||
impl From<NumberSequence> for DomNumberSequence {
|
||||
fn from(v: NumberSequence) -> Self {
|
||||
Self {
|
||||
keypoints: v
|
||||
.keypoints
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(RbxNumberSequenceKeypoint::from)
|
||||
.map(DomNumberSequenceKeypoint::from)
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use core::fmt;
|
||||
|
||||
use mlua::prelude::*;
|
||||
use rbx_dom_weak::types::NumberSequenceKeypoint as RbxNumberSequenceKeypoint;
|
||||
use rbx_dom_weak::types::NumberSequenceKeypoint as DomNumberSequenceKeypoint;
|
||||
|
||||
use super::super::*;
|
||||
|
||||
|
@ -52,8 +52,8 @@ impl fmt::Display for NumberSequenceKeypoint {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RbxNumberSequenceKeypoint> for NumberSequenceKeypoint {
|
||||
fn from(v: RbxNumberSequenceKeypoint) -> Self {
|
||||
impl From<DomNumberSequenceKeypoint> for NumberSequenceKeypoint {
|
||||
fn from(v: DomNumberSequenceKeypoint) -> Self {
|
||||
Self {
|
||||
time: v.time,
|
||||
value: v.value,
|
||||
|
@ -62,7 +62,7 @@ impl From<RbxNumberSequenceKeypoint> for NumberSequenceKeypoint {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<NumberSequenceKeypoint> for RbxNumberSequenceKeypoint {
|
||||
impl From<NumberSequenceKeypoint> for DomNumberSequenceKeypoint {
|
||||
fn from(v: NumberSequenceKeypoint) -> Self {
|
||||
Self {
|
||||
time: v.time,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use core::fmt;
|
||||
|
||||
use mlua::prelude::*;
|
||||
use rbx_dom_weak::types::CustomPhysicalProperties as RbxCustomPhysicalProperties;
|
||||
use rbx_dom_weak::types::CustomPhysicalProperties as DomCustomPhysicalProperties;
|
||||
|
||||
use super::{super::*, EnumItem};
|
||||
|
||||
|
@ -109,8 +109,8 @@ impl fmt::Display for PhysicalProperties {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RbxCustomPhysicalProperties> for PhysicalProperties {
|
||||
fn from(v: RbxCustomPhysicalProperties) -> Self {
|
||||
impl From<DomCustomPhysicalProperties> for PhysicalProperties {
|
||||
fn from(v: DomCustomPhysicalProperties) -> Self {
|
||||
Self {
|
||||
density: v.density,
|
||||
friction: v.friction,
|
||||
|
@ -121,9 +121,9 @@ impl From<RbxCustomPhysicalProperties> for PhysicalProperties {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<PhysicalProperties> for RbxCustomPhysicalProperties {
|
||||
impl From<PhysicalProperties> for DomCustomPhysicalProperties {
|
||||
fn from(v: PhysicalProperties) -> Self {
|
||||
RbxCustomPhysicalProperties {
|
||||
DomCustomPhysicalProperties {
|
||||
density: v.density,
|
||||
friction: v.friction,
|
||||
friction_weight: v.friction_weight,
|
||||
|
|
|
@ -2,7 +2,7 @@ use core::fmt;
|
|||
|
||||
use glam::Vec3;
|
||||
use mlua::prelude::*;
|
||||
use rbx_dom_weak::types::Ray as RbxRay;
|
||||
use rbx_dom_weak::types::Ray as DomRay;
|
||||
|
||||
use super::{super::*, Vector3};
|
||||
|
||||
|
@ -73,8 +73,8 @@ impl fmt::Display for Ray {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RbxRay> for Ray {
|
||||
fn from(v: RbxRay) -> Self {
|
||||
impl From<DomRay> for Ray {
|
||||
fn from(v: DomRay) -> Self {
|
||||
Ray {
|
||||
origin: Vector3::from(v.origin).0,
|
||||
direction: Vector3::from(v.direction).0,
|
||||
|
@ -82,9 +82,9 @@ impl From<RbxRay> for Ray {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Ray> for RbxRay {
|
||||
impl From<Ray> for DomRay {
|
||||
fn from(v: Ray) -> Self {
|
||||
RbxRay {
|
||||
DomRay {
|
||||
origin: Vector3(v.origin).into(),
|
||||
direction: Vector3(v.direction).into(),
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::ops;
|
|||
|
||||
use glam::Vec2;
|
||||
use mlua::prelude::*;
|
||||
use rbx_dom_weak::types::Rect as RbxRect;
|
||||
use rbx_dom_weak::types::Rect as DomRect;
|
||||
|
||||
use super::{super::*, Vector2};
|
||||
|
||||
|
@ -99,8 +99,8 @@ impl ops::Sub for Rect {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RbxRect> for Rect {
|
||||
fn from(v: RbxRect) -> Self {
|
||||
impl From<DomRect> for Rect {
|
||||
fn from(v: DomRect) -> Self {
|
||||
Rect {
|
||||
min: Vec2::new(v.min.x, v.min.y),
|
||||
max: Vec2::new(v.max.x, v.max.y),
|
||||
|
@ -108,9 +108,9 @@ impl From<RbxRect> for Rect {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Rect> for RbxRect {
|
||||
impl From<Rect> for DomRect {
|
||||
fn from(v: Rect) -> Self {
|
||||
RbxRect {
|
||||
DomRect {
|
||||
min: Vector2(v.min).into(),
|
||||
max: Vector2(v.max).into(),
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ use core::fmt;
|
|||
|
||||
use glam::{Mat4, Vec3};
|
||||
use mlua::prelude::*;
|
||||
use rbx_dom_weak::types::Region3 as RbxRegion3;
|
||||
use rbx_dom_weak::types::Region3 as DomRegion3;
|
||||
|
||||
use super::{super::*, CFrame, Vector3};
|
||||
|
||||
|
@ -60,8 +60,8 @@ impl fmt::Display for Region3 {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RbxRegion3> for Region3 {
|
||||
fn from(v: RbxRegion3) -> Self {
|
||||
impl From<DomRegion3> for Region3 {
|
||||
fn from(v: DomRegion3) -> Self {
|
||||
Region3 {
|
||||
min: Vector3::from(v.min).0,
|
||||
max: Vector3::from(v.max).0,
|
||||
|
@ -69,9 +69,9 @@ impl From<RbxRegion3> for Region3 {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Region3> for RbxRegion3 {
|
||||
impl From<Region3> for DomRegion3 {
|
||||
fn from(v: Region3) -> Self {
|
||||
RbxRegion3 {
|
||||
DomRegion3 {
|
||||
min: Vector3(v.min).into(),
|
||||
max: Vector3(v.max).into(),
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ use core::fmt;
|
|||
|
||||
use glam::IVec3;
|
||||
use mlua::prelude::*;
|
||||
use rbx_dom_weak::types::Region3int16 as RbxRegion3int16;
|
||||
use rbx_dom_weak::types::Region3int16 as DomRegion3int16;
|
||||
|
||||
use super::{super::*, Vector3int16};
|
||||
|
||||
|
@ -50,8 +50,8 @@ impl fmt::Display for Region3int16 {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RbxRegion3int16> for Region3int16 {
|
||||
fn from(v: RbxRegion3int16) -> Self {
|
||||
impl From<DomRegion3int16> for Region3int16 {
|
||||
fn from(v: DomRegion3int16) -> Self {
|
||||
Region3int16 {
|
||||
min: Vector3int16::from(v.min).0,
|
||||
max: Vector3int16::from(v.max).0,
|
||||
|
@ -59,9 +59,9 @@ impl From<RbxRegion3int16> for Region3int16 {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Region3int16> for RbxRegion3int16 {
|
||||
impl From<Region3int16> for DomRegion3int16 {
|
||||
fn from(v: Region3int16) -> Self {
|
||||
RbxRegion3int16 {
|
||||
DomRegion3int16 {
|
||||
min: Vector3int16(v.min).into(),
|
||||
max: Vector3int16(v.max).into(),
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ use core::fmt;
|
|||
use std::ops;
|
||||
|
||||
use mlua::prelude::*;
|
||||
use rbx_dom_weak::types::UDim as RbxUDim;
|
||||
use rbx_dom_weak::types::UDim as DomUDim;
|
||||
|
||||
use super::super::*;
|
||||
|
||||
|
@ -95,8 +95,8 @@ impl ops::Sub for UDim {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RbxUDim> for UDim {
|
||||
fn from(v: RbxUDim) -> Self {
|
||||
impl From<DomUDim> for UDim {
|
||||
fn from(v: DomUDim) -> Self {
|
||||
UDim {
|
||||
scale: v.scale,
|
||||
offset: v.offset,
|
||||
|
@ -104,9 +104,9 @@ impl From<RbxUDim> for UDim {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<UDim> for RbxUDim {
|
||||
impl From<UDim> for DomUDim {
|
||||
fn from(v: UDim) -> Self {
|
||||
RbxUDim {
|
||||
DomUDim {
|
||||
scale: v.scale,
|
||||
offset: v.offset,
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::ops;
|
|||
|
||||
use glam::Vec2;
|
||||
use mlua::prelude::*;
|
||||
use rbx_dom_weak::types::UDim2 as RbxUDim2;
|
||||
use rbx_dom_weak::types::UDim2 as DomUDim2;
|
||||
|
||||
use super::{super::*, UDim};
|
||||
|
||||
|
@ -140,8 +140,8 @@ impl ops::Sub for UDim2 {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RbxUDim2> for UDim2 {
|
||||
fn from(v: RbxUDim2) -> Self {
|
||||
impl From<DomUDim2> for UDim2 {
|
||||
fn from(v: DomUDim2) -> Self {
|
||||
UDim2 {
|
||||
x: v.x.into(),
|
||||
y: v.y.into(),
|
||||
|
@ -149,9 +149,9 @@ impl From<RbxUDim2> for UDim2 {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<UDim2> for RbxUDim2 {
|
||||
impl From<UDim2> for DomUDim2 {
|
||||
fn from(v: UDim2) -> Self {
|
||||
RbxUDim2 {
|
||||
DomUDim2 {
|
||||
x: v.x.into(),
|
||||
y: v.y.into(),
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::ops;
|
|||
|
||||
use glam::{Vec2, Vec3};
|
||||
use mlua::prelude::*;
|
||||
use rbx_dom_weak::types::Vector2 as RbxVector2;
|
||||
use rbx_dom_weak::types::Vector2 as DomVector2;
|
||||
|
||||
use super::super::*;
|
||||
|
||||
|
@ -128,14 +128,14 @@ impl ops::Div<f32> for Vector2 {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RbxVector2> for Vector2 {
|
||||
fn from(v: RbxVector2) -> Self {
|
||||
impl From<DomVector2> for Vector2 {
|
||||
fn from(v: DomVector2) -> Self {
|
||||
Vector2(Vec2 { x: v.x, y: v.y })
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vector2> for RbxVector2 {
|
||||
impl From<Vector2> for DomVector2 {
|
||||
fn from(v: Vector2) -> Self {
|
||||
RbxVector2 { x: v.0.x, y: v.0.y }
|
||||
DomVector2 { x: v.0.x, y: v.0.y }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::ops;
|
|||
|
||||
use glam::IVec2;
|
||||
use mlua::prelude::*;
|
||||
use rbx_dom_weak::types::Vector2int16 as RbxVector2int16;
|
||||
use rbx_dom_weak::types::Vector2int16 as DomVector2int16;
|
||||
|
||||
use super::super::*;
|
||||
|
||||
|
@ -103,8 +103,8 @@ impl ops::Div<i32> for Vector2int16 {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RbxVector2int16> for Vector2int16 {
|
||||
fn from(v: RbxVector2int16) -> Self {
|
||||
impl From<DomVector2int16> for Vector2int16 {
|
||||
fn from(v: DomVector2int16) -> Self {
|
||||
Vector2int16(IVec2 {
|
||||
x: v.x.clamp(i16::MIN, i16::MAX) as i32,
|
||||
y: v.y.clamp(i16::MIN, i16::MAX) as i32,
|
||||
|
@ -112,9 +112,9 @@ impl From<RbxVector2int16> for Vector2int16 {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Vector2int16> for RbxVector2int16 {
|
||||
impl From<Vector2int16> for DomVector2int16 {
|
||||
fn from(v: Vector2int16) -> Self {
|
||||
RbxVector2int16 {
|
||||
DomVector2int16 {
|
||||
x: v.0.x.clamp(i16::MIN as i32, i16::MAX as i32) as i16,
|
||||
y: v.0.y.clamp(i16::MIN as i32, i16::MAX as i32) as i16,
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::ops;
|
|||
|
||||
use glam::Vec3;
|
||||
use mlua::prelude::*;
|
||||
use rbx_dom_weak::types::Vector3 as RbxVector3;
|
||||
use rbx_dom_weak::types::Vector3 as DomVector3;
|
||||
|
||||
use super::{super::*, EnumItem};
|
||||
|
||||
|
@ -190,8 +190,8 @@ impl ops::Div<f32> for Vector3 {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RbxVector3> for Vector3 {
|
||||
fn from(v: RbxVector3) -> Self {
|
||||
impl From<DomVector3> for Vector3 {
|
||||
fn from(v: DomVector3) -> Self {
|
||||
Vector3(Vec3 {
|
||||
x: v.x,
|
||||
y: v.y,
|
||||
|
@ -200,9 +200,9 @@ impl From<RbxVector3> for Vector3 {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Vector3> for RbxVector3 {
|
||||
impl From<Vector3> for DomVector3 {
|
||||
fn from(v: Vector3) -> Self {
|
||||
RbxVector3 {
|
||||
DomVector3 {
|
||||
x: v.0.x,
|
||||
y: v.0.y,
|
||||
z: v.0.z,
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::ops;
|
|||
|
||||
use glam::IVec3;
|
||||
use mlua::prelude::*;
|
||||
use rbx_dom_weak::types::Vector3int16 as RbxVector3int16;
|
||||
use rbx_dom_weak::types::Vector3int16 as DomVector3int16;
|
||||
|
||||
use super::super::*;
|
||||
|
||||
|
@ -105,8 +105,8 @@ impl ops::Div<i32> for Vector3int16 {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RbxVector3int16> for Vector3int16 {
|
||||
fn from(v: RbxVector3int16) -> Self {
|
||||
impl From<DomVector3int16> for Vector3int16 {
|
||||
fn from(v: DomVector3int16) -> Self {
|
||||
Vector3int16(IVec3 {
|
||||
x: v.x.clamp(i16::MIN, i16::MAX) as i32,
|
||||
y: v.y.clamp(i16::MIN, i16::MAX) as i32,
|
||||
|
@ -115,9 +115,9 @@ impl From<RbxVector3int16> for Vector3int16 {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Vector3int16> for RbxVector3int16 {
|
||||
impl From<Vector3int16> for DomVector3int16 {
|
||||
fn from(v: Vector3int16) -> Self {
|
||||
RbxVector3int16 {
|
||||
DomVector3int16 {
|
||||
x: v.0.x.clamp(i16::MIN as i32, i16::MAX as i32) as i16,
|
||||
y: v.0.y.clamp(i16::MIN as i32, i16::MAX as i32) as i16,
|
||||
z: v.0.z.clamp(i16::MIN as i32, i16::MAX as i32) as i16,
|
||||
|
|
Loading…
Reference in a new issue