From 5683caffd94c2d6cbca2556973754c7955365b54 Mon Sep 17 00:00:00 2001 From: makspll Date: Thu, 12 Jan 2023 16:02:10 +0000 Subject: [PATCH 01/94] WIP --- bevy_mod_scripting_common/src/derive_flag.rs | 23 --- bevy_mod_scripting_common/src/input.rs | 156 ++++++++++++++++++ bevy_mod_scripting_common/src/lib.rs | 1 + bevy_mod_scripting_derive/src/lib.rs | 45 ++++- bevy_script_api/src/lib.rs | 4 +- examples/wrappers.rs | 6 +- .../bevy_mod_scripting_lua_derive/src/lib.rs | 33 ++-- 7 files changed, 224 insertions(+), 44 deletions(-) create mode 100644 bevy_mod_scripting_common/src/input.rs diff --git a/bevy_mod_scripting_common/src/derive_flag.rs b/bevy_mod_scripting_common/src/derive_flag.rs index c283c7d9e8..aaeb3721b0 100644 --- a/bevy_mod_scripting_common/src/derive_flag.rs +++ b/bevy_mod_scripting_common/src/derive_flag.rs @@ -75,29 +75,6 @@ pub enum DeriveFlag { } ); -// #[derive(PartialEq, Eq, Hash, Debug)] -// pub(crate) struct MethodMacroInvokation { -// pub target: TypePath, -// pub arrow: Token![->], -// pub identifier: LuaMethodType, -// pub paren: Paren, -// pub args: Punctuated, -// } - -// #[allow(clippy::mixed_read_write_in_expression)] -// impl Parse for MethodMacroInvokation { -// fn parse(input: ParseStream) -> Result { -// let f; -// Ok(Self { -// target: input.parse()?, -// arrow: input.parse()?, -// identifier: input.parse()?, -// paren: parenthesized!(f in input), -// args: f.parse_terminated(MethodMacroArg::parse)?, -// }) -// } -// } - #[derive(PartialEq, Eq, Hash)] pub struct AutoMethod { pub docstring: Vec, diff --git a/bevy_mod_scripting_common/src/input.rs b/bevy_mod_scripting_common/src/input.rs new file mode 100644 index 0000000000..7c86765837 --- /dev/null +++ b/bevy_mod_scripting_common/src/input.rs @@ -0,0 +1,156 @@ +use indexmap::IndexSet; +use proc_macro2::Ident; +use syn::{spanned::Spanned, DeriveInput}; + +/// Convenience structure for holding data relevant to proxy generation +pub struct DeriveMeta {} + +#[derive(Debug)] +pub struct Language { + pub name: String, + pub on_feature: Option, +} + +/// Language settings for proxies +#[derive(Default, Debug)] +pub struct LanguageMeta { + pub languages: Vec, +} + +impl TryFrom<(&DeriveInput, syn::MetaList)> for LanguageMeta { + type Error = syn::Error; + + fn try_from(value: (&DeriveInput, syn::MetaList)) -> Result { + let (_, list) = value; + let mut languages: Vec = Default::default(); + + for nested_meta in list.nested.into_iter() { + match nested_meta { + syn::NestedMeta::Lit(syn::Lit::Str(_str)) => { + let mut name = _str.value(); + let mut on_feature = None; + if let Some(postfix) = name.strip_prefix("on_feature(") { + if let Some(middle) = postfix.strip_suffix(')') { + name = middle.to_owned(); + on_feature = Some(name.clone()); + } + } + languages.push(Language { name, on_feature }) + } + _ => { + return Err(syn::Error::new_spanned( + nested_meta, + "Expected language name or wrapped language name", + )) + } + }; + } + + Ok(Self { languages }) + } +} + +/// Flags which detail required functionality or additional derivation requirements +#[derive(Debug, Hash, PartialEq, Eq)] +pub enum DeriveFlag { + Debug, + Display, + Clone, +} + +impl<'a> TryFrom<(&'a DeriveInput, syn::NestedMeta)> for DeriveFlag { + type Error = syn::Error; + + fn try_from(value: (&'a DeriveInput, syn::NestedMeta)) -> Result { + todo!() + } +} + +/// Container for proxy flags +#[derive(Debug, Default)] +pub struct ProxyFlags { + pub derive_flags: IndexSet, + pub functions: +} + +impl<'a> TryFrom<(&'a DeriveInput, syn::MetaList)> for ProxyFlags { + type Error = syn::Error; + + fn try_from(value: (&'a DeriveInput, syn::MetaList)) -> Result { + let (derive_input, meta_list) = value; + let mut flags: IndexSet = Default::default(); + for nested_meta in meta_list.nested { + let span = nested_meta.span(); + let flag: DeriveFlag = (derive_input, nested_meta).try_into()?; + if flags.contains(&flag) { + return Err(syn::Error::new( + span, + "This flag was already defined, remove duplicate flag", + )); + } else { + flags.insert(flag); + } + } + Ok(Self { flags }) + } +} + +/// Attributes relating to the proxy as a whole +#[derive(Debug)] +pub struct ProxyMeta<'a> { + pub proxy_name: Ident, + pub language_meta: LanguageMeta, + pub proxy_flags: ProxyFlags, + pub derive_data: &'a DeriveInput, +} + +impl<'a> TryFrom<(&'a DeriveInput, syn::Meta)> for ProxyMeta<'a> { + type Error = syn::Error; + + fn try_from(value: (&'a DeriveInput, syn::Meta)) -> Result { + let (derive_data, meta) = value; + if let syn::Meta::List(list) = meta { + let mut proxy_name = derive_data.ident.clone(); + let mut language_meta = Default::default(); + let mut proxy_flags = Default::default(); + + for attr in list.nested.into_iter() { + if let syn::NestedMeta::Meta(syn::Meta::NameValue(pair)) = attr { + let ident = pair.path.get_ident().ok_or_else(|| { + syn::Error::new_spanned(&pair, "Keys must be identifiers") + })?; + + match (ident.to_string().as_str(), pair.lit) { + ("name", syn::Lit::Str(_str)) => { + proxy_name = Ident::new(&_str.value(), _str.span()) + } + _ => return Err(syn::Error::new_spanned(ident, "Unrecognized argument")), + } + } else if let syn::NestedMeta::Meta(syn::Meta::List(list)) = attr { + let ident = list + .path + .get_ident() + .ok_or_else(|| syn::Error::new_spanned(&list, "Expected identifier"))?; + + match ident.to_string().as_str() { + "languages" => language_meta = (derive_data, list).try_into()?, + _ => return Err(syn::Error::new_spanned(list, "")), + } + } else { + return Err(syn::Error::new_spanned(attr, "Expected key value pair")); + } + } + Ok(ProxyMeta { + proxy_name, + proxy_flags, + language_meta, + derive_data, + }) + } else { + Err(syn::Error::new_spanned( + meta, + "Expected list of key value pairs", + )) + } + } +} diff --git a/bevy_mod_scripting_common/src/lib.rs b/bevy_mod_scripting_common/src/lib.rs index 3dbaf8d5b1..d4dcff44b4 100644 --- a/bevy_mod_scripting_common/src/lib.rs +++ b/bevy_mod_scripting_common/src/lib.rs @@ -2,6 +2,7 @@ pub mod arg; pub mod derive_data; pub mod derive_flag; pub mod implementor; +pub mod input; pub mod newtype; pub mod ops; pub mod utils; diff --git a/bevy_mod_scripting_derive/src/lib.rs b/bevy_mod_scripting_derive/src/lib.rs index 745d7363a8..8611978bc0 100644 --- a/bevy_mod_scripting_derive/src/lib.rs +++ b/bevy_mod_scripting_derive/src/lib.rs @@ -1,8 +1,45 @@ #![allow(dead_code, unused_variables, unused_features)] +use bevy_mod_scripting_common::input::ProxyMeta; use proc_macro::TokenStream; -use quote::{format_ident, quote_spanned, ToTokens}; -use syn::{parse::Parse, parse_macro_input, spanned::Spanned, Attribute}; +use quote::{format_ident, quote, quote_spanned, ToTokens}; +use syn::{parse::Parse, parse_macro_input, spanned::Spanned, Attribute, DeriveInput}; + +#[proc_macro_derive(ScriptProxy, attributes(proxy, rhai, lua))] +pub fn make_script_proxy(input: TokenStream) -> TokenStream { + let original_tokens: proc_macro2::TokenStream = input.clone().into(); + let derive_input = parse_macro_input!(input as DeriveInput); + + let attrs: Result = derive_input + .attrs + .iter() + .filter_map(|attr| attr.parse_meta().ok()) + .find(|attr| attr.path().is_ident("proxy")) + .ok_or_else(|| syn::Error::new_spanned(&derive_input, "`proxy` meta missing")) + .and_then(|attr| (&derive_input, attr).try_into()); + + match attrs { + Ok(attrs) => { + let mut tokens: Vec = Default::default(); + for lang in attrs.language_meta.languages { + let macro_ident = format_ident!("impl_{}_proxy", lang.name); + let feature_gate = lang + .on_feature + .map(|feature| quote!(#[cfg(feature=#feature)])) + .unwrap_or_default(); + + tokens.push(TokenStream::from(quote::quote! { + #feature_gate + bevy_mod_scripting::api::#macro_ident!{ + #original_tokens + }; + })); + } + tokens.into_iter().collect() + } + Err(err) => err.to_compile_error().into(), + } +} /// A convenience macro which derives a lotta things to make your type work in all supported/enabled scripting languages, and provide static typing where possible. /// @@ -58,6 +95,10 @@ use syn::{parse::Parse, parse_macro_input, spanned::Spanned, Attribute}; /// println!("{:?}", std::any::TypeId::Of::); /// ``` #[proc_macro] +#[deprecated( + note = "this macro will be removed in the next release, please use the new derive macros", + since = "0.3.0" +)] pub fn impl_script_newtype(input: TokenStream) -> TokenStream { let invocation = parse_macro_input!(input as MacroInvocation); let mut output: proc_macro2::TokenStream = Default::default(); diff --git a/bevy_script_api/src/lib.rs b/bevy_script_api/src/lib.rs index f41ac710e4..48f8954e9f 100644 --- a/bevy_script_api/src/lib.rs +++ b/bevy_script_api/src/lib.rs @@ -35,9 +35,9 @@ pub mod prelude { } // re-export derive macros from other langs -pub use bevy_mod_scripting_derive::impl_script_newtype; +pub use bevy_mod_scripting_derive::{impl_script_newtype, ScriptProxy}; #[cfg(feature = "lua")] -pub use bevy_mod_scripting_lua_derive::impl_lua_newtype; //LuaProxy}; +pub use bevy_mod_scripting_lua_derive::impl_lua_newtype; pub(crate) mod generated; diff --git a/examples/wrappers.rs b/examples/wrappers.rs index bbf6084f28..9e2602f72f 100644 --- a/examples/wrappers.rs +++ b/examples/wrappers.rs @@ -1,7 +1,7 @@ use bevy::{app::AppExit, prelude::*}; use bevy_mod_scripting::{ - api::{impl_lua_newtype, impl_script_newtype, lua::bevy::LuaWorld, ScriptRef}, + api::{impl_lua_newtype, impl_script_newtype, lua::bevy::LuaWorld, ScriptProxy, ScriptRef}, prelude::*, }; @@ -19,6 +19,10 @@ pub struct MyThing { string: String, } +#[derive(ScriptProxy)] +#[proxy(languages("on_feature(lua)"))] +pub struct Lol {} + impl MyThing { pub fn do_something_cool(&self) -> String { self.string.clone() diff --git a/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/languages/bevy_mod_scripting_lua_derive/src/lib.rs index 1ba10a31e6..4124a03383 100644 --- a/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -1,8 +1,10 @@ -use bevy_mod_scripting_common::{implementor::WrapperImplementor, newtype::Newtype}; +use bevy_mod_scripting_common::{ + implementor::WrapperImplementor, input::ProxyMeta, newtype::Newtype, +}; use implementor::LuaImplementor; // use impls::{impl_enum, impl_struct}; use proc_macro::TokenStream; -use syn::parse_macro_input; +use syn::{parse_macro_input, DeriveInput}; pub(crate) mod derive_flags; pub(crate) mod implementor; @@ -21,18 +23,17 @@ pub fn impl_lua_newtype(tokens: TokenStream) -> TokenStream { .into() } -// #[proc_macro_derive(LuaProxy, attributes(lua, scripting))] -// pub fn lua_derive(input: TokenStream) -> TokenStream { -// let input = parse_macro_input!(input as DeriveInput); -// let data: Result = (&input).try_into(); +#[proc_macro] +pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { + let derive_input = parse_macro_input!(input as DeriveInput); + + let meta: Result = derive_input + .attrs + .iter() + .filter_map(|attr| attr.parse_meta().ok()) + .find(|attr| attr.path().is_ident("proxy")) + .ok_or_else(|| syn::Error::new_spanned(&derive_input, "`proxy` meta missing")) + .and_then(|attr| (&derive_input, attr).try_into()); -// TokenStream::from(match data { -// Ok(data) => match data { -// ProxyData::Struct(data) -// | ProxyData::TupleStruct(data) -// | ProxyData::UnitStruct(data) => impl_struct(data), -// ProxyData::Enum(data) => impl_enum(data), -// }, -// Err(error) => error.to_compile_error(), -// }) -// } + Default::default() +} From 5dddc308d041bcf2dfefb41581e5fdb6932b1baf Mon Sep 17 00:00:00 2001 From: makspll Date: Thu, 12 Jan 2023 21:30:26 +0000 Subject: [PATCH 02/94] WIP --- bevy_mod_scripting_common/src/input.rs | 119 ++++++++++++------ bevy_mod_scripting_derive/src/lib.rs | 8 +- .../bevy_mod_scripting_lua_derive/src/lib.rs | 8 +- 3 files changed, 85 insertions(+), 50 deletions(-) diff --git a/bevy_mod_scripting_common/src/input.rs b/bevy_mod_scripting_common/src/input.rs index 7c86765837..91feda71c0 100644 --- a/bevy_mod_scripting_common/src/input.rs +++ b/bevy_mod_scripting_common/src/input.rs @@ -1,6 +1,11 @@ -use indexmap::IndexSet; +use indexmap::{IndexMap, IndexSet}; use proc_macro2::Ident; -use syn::{spanned::Spanned, DeriveInput}; +use syn::{ + parse::{Nothing, Parse}, + punctuated::Punctuated, + spanned::Spanned, + DataStruct, DeriveInput, Fields, TraitItemMethod, +}; /// Convenience structure for holding data relevant to proxy generation pub struct DeriveMeta {} @@ -17,11 +22,10 @@ pub struct LanguageMeta { pub languages: Vec, } -impl TryFrom<(&DeriveInput, syn::MetaList)> for LanguageMeta { +impl TryFrom for LanguageMeta { type Error = syn::Error; - fn try_from(value: (&DeriveInput, syn::MetaList)) -> Result { - let (_, list) = value; + fn try_from(list: syn::MetaList) -> Result { let mut languages: Vec = Default::default(); for nested_meta in list.nested.into_iter() { @@ -58,10 +62,10 @@ pub enum DeriveFlag { Clone, } -impl<'a> TryFrom<(&'a DeriveInput, syn::NestedMeta)> for DeriveFlag { +impl TryFrom for DeriveFlag { type Error = syn::Error; - fn try_from(value: (&'a DeriveInput, syn::NestedMeta)) -> Result { + fn try_from(value: syn::NestedMeta) -> Result { todo!() } } @@ -70,50 +74,85 @@ impl<'a> TryFrom<(&'a DeriveInput, syn::NestedMeta)> for DeriveFlag { #[derive(Debug, Default)] pub struct ProxyFlags { pub derive_flags: IndexSet, - pub functions: } -impl<'a> TryFrom<(&'a DeriveInput, syn::MetaList)> for ProxyFlags { +impl TryFrom for ProxyFlags { type Error = syn::Error; - fn try_from(value: (&'a DeriveInput, syn::MetaList)) -> Result { - let (derive_input, meta_list) = value; - let mut flags: IndexSet = Default::default(); + fn try_from(meta_list: syn::MetaList) -> Result { + let mut derive_flags: IndexSet = Default::default(); + for nested_meta in meta_list.nested { let span = nested_meta.span(); - let flag: DeriveFlag = (derive_input, nested_meta).try_into()?; - if flags.contains(&flag) { + let flag: DeriveFlag = nested_meta.try_into()?; + if derive_flags.contains(&flag) { return Err(syn::Error::new( span, "This flag was already defined, remove duplicate flag", )); } else { - flags.insert(flag); + derive_flags.insert(flag); } } - Ok(Self { flags }) + Ok(Self { derive_flags }) + } +} + +pub(crate) struct ZeroOrManyTerminated(Punctuated); + +impl Parse for ZeroOrManyTerminated { + fn parse(input: syn::parse::ParseStream) -> syn::Result { + Ok(Self(Punctuated::::parse_terminated(input)?)) } } +/// Detailed information about the proxy, here we can access fields/variants etc. +#[derive(Debug)] +pub enum ProxyData { + Struct { fields: Fields }, +} + /// Attributes relating to the proxy as a whole #[derive(Debug)] -pub struct ProxyMeta<'a> { +pub struct ProxyMeta { pub proxy_name: Ident, pub language_meta: LanguageMeta, pub proxy_flags: ProxyFlags, - pub derive_data: &'a DeriveInput, + pub functions: IndexMap, + pub data: ProxyData, } -impl<'a> TryFrom<(&'a DeriveInput, syn::Meta)> for ProxyMeta<'a> { +impl TryFrom for ProxyMeta { type Error = syn::Error; - fn try_from(value: (&'a DeriveInput, syn::Meta)) -> Result { - let (derive_data, meta) = value; - if let syn::Meta::List(list) = meta { - let mut proxy_name = derive_data.ident.clone(); - let mut language_meta = Default::default(); - let mut proxy_flags = Default::default(); - + fn try_from(derive_input: DeriveInput) -> Result { + let mut proxy_name = derive_input.ident.clone(); + + let proxy_meta = derive_input + .attrs + .iter() + .find(|attr| attr.path.is_ident("proxy")) + .ok_or_else(|| syn::Error::new_spanned(&derive_input, "`proxy` meta missing")) + .and_then(|attr| attr.parse_meta())?; + + let functions = derive_input + .attrs + .into_iter() + .find(|attr| attr.path.is_ident("functions")) + .map_or(Ok(IndexMap::default()), |attr| { + syn::parse::>(attr.tokens.into()) + .map(|fns| { + fns.0 + .into_iter() + .map(|_fn| (_fn.sig.ident.clone(), _fn)) + .collect::>() + }) + })?; + + let mut language_meta = Default::default(); + let proxy_flags = Default::default(); + + if let syn::Meta::List(list) = proxy_meta { for attr in list.nested.into_iter() { if let syn::NestedMeta::Meta(syn::Meta::NameValue(pair)) = attr { let ident = pair.path.get_ident().ok_or_else(|| { @@ -133,24 +172,32 @@ impl<'a> TryFrom<(&'a DeriveInput, syn::Meta)> for ProxyMeta<'a> { .ok_or_else(|| syn::Error::new_spanned(&list, "Expected identifier"))?; match ident.to_string().as_str() { - "languages" => language_meta = (derive_data, list).try_into()?, + "languages" => language_meta = list.try_into()?, _ => return Err(syn::Error::new_spanned(list, "")), } } else { return Err(syn::Error::new_spanned(attr, "Expected key value pair")); } } - Ok(ProxyMeta { - proxy_name, - proxy_flags, - language_meta, - derive_data, - }) } else { - Err(syn::Error::new_spanned( - meta, + return Err(syn::Error::new_spanned( + proxy_meta, "Expected list of key value pairs", - )) + )); } + + let data = match derive_input.data { + syn::Data::Struct(DataStruct { fields, .. }) => ProxyData::Struct { fields }, + syn::Data::Enum(_) => todo!(), + syn::Data::Union(_) => todo!(), + }; + + Ok(ProxyMeta { + proxy_name, + proxy_flags, + language_meta, + functions, + data, + }) } } diff --git a/bevy_mod_scripting_derive/src/lib.rs b/bevy_mod_scripting_derive/src/lib.rs index 8611978bc0..d71509dafc 100644 --- a/bevy_mod_scripting_derive/src/lib.rs +++ b/bevy_mod_scripting_derive/src/lib.rs @@ -10,13 +10,7 @@ pub fn make_script_proxy(input: TokenStream) -> TokenStream { let original_tokens: proc_macro2::TokenStream = input.clone().into(); let derive_input = parse_macro_input!(input as DeriveInput); - let attrs: Result = derive_input - .attrs - .iter() - .filter_map(|attr| attr.parse_meta().ok()) - .find(|attr| attr.path().is_ident("proxy")) - .ok_or_else(|| syn::Error::new_spanned(&derive_input, "`proxy` meta missing")) - .and_then(|attr| (&derive_input, attr).try_into()); + let attrs: Result = derive_input.try_into(); match attrs { Ok(attrs) => { diff --git a/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/languages/bevy_mod_scripting_lua_derive/src/lib.rs index 4124a03383..77d36247c0 100644 --- a/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -27,13 +27,7 @@ pub fn impl_lua_newtype(tokens: TokenStream) -> TokenStream { pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { let derive_input = parse_macro_input!(input as DeriveInput); - let meta: Result = derive_input - .attrs - .iter() - .filter_map(|attr| attr.parse_meta().ok()) - .find(|attr| attr.path().is_ident("proxy")) - .ok_or_else(|| syn::Error::new_spanned(&derive_input, "`proxy` meta missing")) - .and_then(|attr| (&derive_input, attr).try_into()); + let meta: Result = derive_input.try_into(); Default::default() } From 52b589b6a274eeaa68ed74df091c2958a1948da3 Mon Sep 17 00:00:00 2001 From: makspll Date: Sun, 14 May 2023 09:15:29 +0100 Subject: [PATCH 03/94] WIP --- bevy_mod_scripting_common/src/input.rs | 62 ++- bevy_mod_scripting_derive/src/lib.rs | 2 +- bevy_script_api/src/lib.rs | 4 +- examples/wrappers.rs | 15 +- .../bevy_mod_scripting_lua_derive/Cargo.toml | 1 + .../bevy_mod_scripting_lua_derive/src/lib.rs | 366 +++++++++++++++++- 6 files changed, 435 insertions(+), 15 deletions(-) diff --git a/bevy_mod_scripting_common/src/input.rs b/bevy_mod_scripting_common/src/input.rs index 91feda71c0..af9dbb6d4e 100644 --- a/bevy_mod_scripting_common/src/input.rs +++ b/bevy_mod_scripting_common/src/input.rs @@ -1,12 +1,18 @@ +use std::collections::VecDeque; + use indexmap::{IndexMap, IndexSet}; -use proc_macro2::Ident; +use proc_macro2::{Ident, Span}; +use quote::TokenStreamExt; use syn::{ - parse::{Nothing, Parse}, + bracketed, parenthesized, + parse::{Nothing, Parse, ParseBuffer}, punctuated::Punctuated, spanned::Spanned, - DataStruct, DeriveInput, Fields, TraitItemMethod, + Attribute, DataStruct, DeriveInput, Fields, TraitItemMethod, }; +use crate::utils::attribute_to_string_lit; + /// Convenience structure for holding data relevant to proxy generation pub struct DeriveMeta {} @@ -73,7 +79,7 @@ impl TryFrom for DeriveFlag { /// Container for proxy flags #[derive(Debug, Default)] pub struct ProxyFlags { - pub derive_flags: IndexSet, + pub flags: IndexSet, } impl TryFrom for ProxyFlags { @@ -94,7 +100,9 @@ impl TryFrom for ProxyFlags { derive_flags.insert(flag); } } - Ok(Self { derive_flags }) + Ok(Self { + flags: derive_flags, + }) } } @@ -115,11 +123,22 @@ pub enum ProxyData { /// Attributes relating to the proxy as a whole #[derive(Debug)] pub struct ProxyMeta { + /// the identifier of the proxied type + pub proxied_name: Ident, + /// the identifier for the proxy type pub proxy_name: Ident, + /// language derivation settings pub language_meta: LanguageMeta, + /// additional flags for the proxy pub proxy_flags: ProxyFlags, + /// functions to be proxied pub functions: IndexMap, + /// the inner type data pub data: ProxyData, + /// the derive input span + pub span: Span, + /// docstrings + pub docstrings: Vec, } impl TryFrom for ProxyMeta { @@ -127,6 +146,17 @@ impl TryFrom for ProxyMeta { fn try_from(derive_input: DeriveInput) -> Result { let mut proxy_name = derive_input.ident.clone(); + let span = derive_input.span(); + + // helper for collecting errors which are not fatal to the logic flow + // simplifies logical flow + let mut accumulated_errors = VecDeque::::default(); + + let docstrings = derive_input + .attrs + .iter() + .map(attribute_to_string_lit) + .collect(); let proxy_meta = derive_input .attrs @@ -140,12 +170,21 @@ impl TryFrom for ProxyMeta { .into_iter() .find(|attr| attr.path.is_ident("functions")) .map_or(Ok(IndexMap::default()), |attr| { - syn::parse::>(attr.tokens.into()) + attr.parse_args::>() .map(|fns| { + let mut fn_map = IndexMap::default(); fns.0 .into_iter() .map(|_fn| (_fn.sig.ident.clone(), _fn)) - .collect::>() + .for_each(|(name, body)| { + if let Some(old_val) = fn_map.insert(name, body) { + accumulated_errors.push_back(syn::Error::new_spanned( + old_val.sig.ident, // old == new ident + "duplicate Lua proxy function, re-name this function", + )) + } + }); + fn_map }) })?; @@ -192,12 +231,21 @@ impl TryFrom for ProxyMeta { syn::Data::Union(_) => todo!(), }; + let proxied_name = derive_input.ident; + + if let Some(first_err) = accumulated_errors.pop_front() { + return Err(first_err); + } + Ok(ProxyMeta { + proxied_name, proxy_name, proxy_flags, language_meta, functions, data, + span, + docstrings, }) } } diff --git a/bevy_mod_scripting_derive/src/lib.rs b/bevy_mod_scripting_derive/src/lib.rs index d71509dafc..ade12a2cc4 100644 --- a/bevy_mod_scripting_derive/src/lib.rs +++ b/bevy_mod_scripting_derive/src/lib.rs @@ -5,7 +5,7 @@ use proc_macro::TokenStream; use quote::{format_ident, quote, quote_spanned, ToTokens}; use syn::{parse::Parse, parse_macro_input, spanned::Spanned, Attribute, DeriveInput}; -#[proc_macro_derive(ScriptProxy, attributes(proxy, rhai, lua))] +#[proc_macro_derive(ScriptProxy, attributes(functions, proxy, rhai, lua))] pub fn make_script_proxy(input: TokenStream) -> TokenStream { let original_tokens: proc_macro2::TokenStream = input.clone().into(); let derive_input = parse_macro_input!(input as DeriveInput); diff --git a/bevy_script_api/src/lib.rs b/bevy_script_api/src/lib.rs index 48f8954e9f..98b4058ee9 100644 --- a/bevy_script_api/src/lib.rs +++ b/bevy_script_api/src/lib.rs @@ -17,7 +17,7 @@ pub use {script_ref::*, sub_reflect::*}; pub mod prelude { #[cfg(feature = "lua")] pub use crate::{ - impl_lua_newtype, + impl_lua_newtype, impl_lua_proxy, lua::{ bevy::LuaBevyAPIProvider, std::LuaVec, FromLuaProxy, LuaProxyable, ReflectLuaProxyable, ToLuaProxy, @@ -37,7 +37,7 @@ pub mod prelude { // re-export derive macros from other langs pub use bevy_mod_scripting_derive::{impl_script_newtype, ScriptProxy}; #[cfg(feature = "lua")] -pub use bevy_mod_scripting_lua_derive::impl_lua_newtype; +pub use bevy_mod_scripting_lua_derive::{impl_lua_newtype, impl_lua_proxy}; pub(crate) mod generated; diff --git a/examples/wrappers.rs b/examples/wrappers.rs index d028028351..12ceb70f1b 100644 --- a/examples/wrappers.rs +++ b/examples/wrappers.rs @@ -19,8 +19,21 @@ pub struct MyThing { string: String, } -#[derive(ScriptProxy)] +#[derive(ScriptProxy, Reflect)] #[proxy(languages("on_feature(lua)"))] +#[functions[ + + // #[lua(MutatingMetaMethod)] + // fn basd(mut self) { + + // } + + // #[lua(MetaMethod)] + // fn asd(self); + + #[lua(Method)] + fn basda(self); +]] pub struct Lol {} impl MyThing { diff --git a/languages/bevy_mod_scripting_lua_derive/Cargo.toml b/languages/bevy_mod_scripting_lua_derive/Cargo.toml index fbb15c9e58..c130c4614b 100644 --- a/languages/bevy_mod_scripting_lua_derive/Cargo.toml +++ b/languages/bevy_mod_scripting_lua_derive/Cargo.toml @@ -33,3 +33,4 @@ rustdoc-types = "0.11.0" serde = { version = "1.0", features = ["derive"] } serde_derive = "1.0.137" indexmap = {version= "1.9.1", features= ["serde"]} +proc-macro-error = "1" \ No newline at end of file diff --git a/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/languages/bevy_mod_scripting_lua_derive/src/lib.rs index 77d36247c0..742ee58712 100644 --- a/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -1,10 +1,15 @@ use bevy_mod_scripting_common::{ - implementor::WrapperImplementor, input::ProxyMeta, newtype::Newtype, + implementor::WrapperImplementor, + input::{DeriveFlag, ProxyMeta}, + newtype::Newtype, utils::attribute_to_string_lit, }; use implementor::LuaImplementor; // use impls::{impl_enum, impl_struct}; use proc_macro::TokenStream; -use syn::{parse_macro_input, DeriveInput}; +use proc_macro2::{Ident, Span}; +use proc_macro_error::{proc_macro_error, abort, emit_error}; +use quote::{quote_spanned, format_ident, quote, ToTokens}; +use syn::{parse_macro_input, DeriveInput, TraitItemMethod, MetaList, Meta, NestedMeta, Error, FnArg, spanned::Spanned, TypePath, parse_quote, PatType, Attribute, Lit, token::Mut}; pub(crate) mod derive_flags; pub(crate) mod implementor; @@ -23,11 +28,364 @@ pub fn impl_lua_newtype(tokens: TokenStream) -> TokenStream { .into() } +struct FunctionArgMeta<'a> { + fn_arg: &'a FnArg, + is_receiver: bool, + is_a_lua_proxy: bool, + mutable: Option, + /// the processed type path, for proxies outer references are stripped + type_path: TypePath, + arg_name: Ident, +} + +impl <'a>From<(&'a Ident,&'a FnArg)> for FunctionArgMeta<'a>{ + /// Parse function argument meta using the proxy type name and the actual syn::FnArg + /// type_path will be replaced with the proxy type name for receiver args + /// arguments which are annotated with #[proxy] and #[proxy("name")] attributes are resolved as proxies with the type path + /// resolving to their proxy name + fn from((proxy_name, fn_arg): (&'a Ident,&'a FnArg)) -> Self { + let is_a_lua_proxy; + let type_path; + let arg_name; + let mutable; + let is_receiver; + match fn_arg { + FnArg::Receiver(receiver) => { + is_receiver = true; + is_a_lua_proxy = true; + type_path = parse_quote!(#proxy_name); + + if let Some(_mut) = receiver.mutability { + mutable = Some(_mut) + } else { + mutable = None + } + + arg_name = format_ident!("_self"); + }, + FnArg::Typed(PatType{ attrs, pat, ty , ..}) => { + is_receiver = false; + let proxy_attr = attrs.iter() + .find_map(|attr| attr.path.is_ident("proxy").then_some(attr)); + + is_a_lua_proxy = proxy_attr.is_some(); + mutable = proxy_attr.is_some().then(|| parse_quote!(mut)); + + let passed_proxy_name = proxy_attr + .map(|attr| attr.parse_meta().unwrap_or_else(|err| abort!(attr, err))) + .map(|meta| match meta { + Meta::Path(_) => generate_automatic_proxy_name(proxy_name), + Meta::List(MetaList{ nested, .. }) => { + if let Some(NestedMeta::Lit(Lit::Str(proxy_name))) = nested.first() { + return format_ident!("{}", proxy_name.token().to_string()) + } + abort!(nested, "Expected single item attribute list containing proxy name as in: `proxy(\"proxy_name\")`"); + }, + Meta::NameValue(name_val) => abort!(name_val, "Expected single item attribute list containing proxy name as in: `proxy(\"proxy_name\")`") + }); + + if let Some(name) = passed_proxy_name { + type_path = parse_quote!(#name); + } else { + type_path = parse_quote!(#ty); + } + + arg_name = parse_quote!(#pat); + }, + } + + FunctionArgMeta { + fn_arg, + is_receiver, + is_a_lua_proxy, + mutable, + type_path, + arg_name + } + } +} + +struct FunctionMeta<'a> { + name: &'a Ident, + body: &'a TraitItemMethod, + fn_type: FunctionType, + arg_meta: Vec> +} + + +impl FunctionMeta<'_> { + + fn validate_function_definition(&self, definition: &TraitItemMethod) { + if self.fn_type.expects_receiver() { + if let Some(FnArg::Receiver(receiver)) = definition.sig.receiver() { + // validate receiver + if receiver.reference.is_some() { + emit_error!(receiver, "Proxy receivers can only be one of: `self` or `mut self`, Proxies have pass by value semantics.") + } + if self.fn_type.expects_mutable_receiver() && receiver.mutability.is_none() { + emit_error!(receiver, format!("Lua proxy functions of type: {}, require `mut self` argument", self.fn_type.as_str())); + } + } else { + emit_error!(definition, format!("Lua proxy functions of type: {}, require `self` argument", self.fn_type.as_str())) + } + } + } +} + + +#[derive(PartialEq,Eq,Clone,Copy)] +enum FunctionType { + Function, + MetaFunction, + Method, + MetaMethod, + MutableFunction, + MutableMetaFunction, + MutatingMethod, + MutatingMetaMethod, +} + +impl FunctionType { + pub fn as_str(self) -> &'static str { + match self { + FunctionType::Function => "Function", + FunctionType::MetaFunction => "Meta Function", + FunctionType::Method => "Method", + FunctionType::MetaMethod => "Meta Method", + FunctionType::MutableFunction => "Mutating Function", + FunctionType::MutableMetaFunction => "Mutable Meta Function", + FunctionType::MutatingMethod => "Mutating Method", + FunctionType::MutatingMetaMethod => "Mutating Meta Method", + } + } + + pub fn from_str(str: &str) -> Result { + match str { + "Function" => Ok(FunctionType::Function), + "MetaFunction" => Ok(FunctionType::MetaFunction), + "Method" => Ok(FunctionType::Method), + "MetaMethod" => Ok(FunctionType::MetaMethod), + "MutableFunction" => Ok(FunctionType::MutableFunction), + "MutableMetaFunction" => Ok(FunctionType::MutableMetaFunction), + "MutatingMethod" => Ok(FunctionType::MutatingMethod), + "MutatingMetaMethod" => Ok(FunctionType::MutatingMetaMethod), + _ => Err(()) + } + } + + + pub fn as_ident_str(self) -> String { + self.as_str().split_whitespace().collect() + } + + pub fn iterator() -> impl Iterator { + [FunctionType::Function, + FunctionType::Method, + FunctionType::MetaMethod, + FunctionType::MetaFunction, + FunctionType::MutableFunction, + FunctionType::MutatingMethod, + FunctionType::MutatingMetaMethod, + FunctionType::MutableMetaFunction].into_iter() + } + + fn expects_receiver(self) -> bool { + self == FunctionType::Method || + self == FunctionType::MetaMethod || + self == FunctionType::MutatingMethod || + self == FunctionType::MutatingMetaMethod + } + + fn expects_mutable_receiver(self) -> bool { + self == FunctionType::MutatingMethod || + self == FunctionType::MutatingMetaMethod + } + + fn get_tealr_function(self) -> &'static str{ + match self { + FunctionType::Function => "add_function", + FunctionType::MetaFunction => "add_meta_function", + FunctionType::Method => "add_method", + FunctionType::MetaMethod => "add_meta_method", + FunctionType::MutableFunction => "add_function_mut", + FunctionType::MutableMetaFunction => "add_meta_function_mut", + FunctionType::MutatingMethod => "add_method_mut", + FunctionType::MutatingMetaMethod => "add_meta_method_mut", + } + } + + fn is_meta(self) -> bool { + self == FunctionType::MetaMethod || + self == FunctionType::MetaFunction || + self == FunctionType::MutatingMetaMethod || + self == FunctionType::MutableMetaFunction + } + +} + +#[proc_macro_error] #[proc_macro] pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { let derive_input = parse_macro_input!(input as DeriveInput); - let meta: Result = derive_input.try_into(); + let meta: ProxyMeta = match derive_input.try_into() { + Ok(meta) => meta, + Err(err) => return err.to_compile_error().into(), + }; + + let proxy_name = + if meta.proxy_name == meta.proxied_name { + generate_automatic_proxy_name(&meta.proxy_name) + } else { + meta.proxy_name + }; + + let proxied_name = meta.proxied_name; + let is_clonable = meta.proxy_flags.flags.contains(&DeriveFlag::Clone); + + // generate the type definition of the proxy + let mut definition: proc_macro2::TokenStream; + if is_clonable { + definition = quote_spanned! {meta.span=> + bevy_script_api::make_script_wrapper!(#proxied_name as #proxy_name with Clone); + }; + } else { + definition = quote_spanned! {meta.span=> + bevy_script_api::make_script_wrapper!(#proxied_name as #proxy_name); + } + } + + if meta.proxy_flags.flags.contains(&DeriveFlag::Debug) { + definition.extend(quote_spanned!{meta.span=> + impl std::fmt::Debug for #proxy_name { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { + self.val(|s| s.fmt(f)).unwrap_or_else(|_| f.write_str("Error while retrieving reference in `std::fmt::Debug`."))} + } + }); + } + + let tealr_type_implementations = quote_spanned!{meta.span=> + bevy_script_api::impl_tealr_type!(#proxy_name); + }; + + // generate type level tealr documentation calls + let type_level_document_calls = + meta.docstrings + .iter() + .map(|tkns| + quote_spanned!(meta.span=>methods.document_type(#tkns);)); + + // generate both tealr documentation and instantiations of functions + let methods = meta.functions + .iter() + .map(|(name, body)| { + + let method_documentation_calls = body.attrs.iter() + .map(attribute_to_string_lit) + .map(|ts| quote_spanned!(body.span()=>methods.document_type(#ts);)); + + let fn_meta = generate_function_meta(&proxy_name, name, body); + let tealr_function = format_ident!("{}",fn_meta.fn_type.get_tealr_function()); + let signature = fn_meta.fn_type + .is_meta() + .then(|| fn_meta.name.to_token_stream()) + .unwrap_or_else(|| fn_meta.name.to_string().to_token_stream()); + + let closure_args = fn_meta.arg_meta + .iter() + .map(|fn_arg| { + let _mut = &fn_arg.mutable; + let name = &fn_arg.arg_name; + let type_path = &fn_arg.type_path; + quote_spanned!(fn_arg.fn_arg.span()=>#_mut #name : #type_path) + }); + + let closure = quote_spanned!{body.span()=> + |_ #(, #closure_args)*| { + Ok(()) + } + }; + + + quote_spanned!{body.span()=> + #(#method_documentation_calls)* + methods.#tealr_function(#signature, #closure); + } + }); + panic!("{}", methods.collect::()); + + let tealr = quote!(bevy_mod_scripting_lua::tealr); + + quote_spanned!{meta.span=> + + #definition - Default::default() + #tealr_type_implementations + + #[automatically_derived] + impl #tealr::mlu::TealData for #proxy_name { + fn add_methods<'lua, T: #tealr::mlu::TealDataMethods<'lua, Self>>(methods: &mut T) { + #(#type_level_document_calls)* + #(#methods)* + } + + fn add_fields<'lua, T: #tealr::mlu::TealDataFields<'lua, Self>>(fields: &mut T) { + + } + } + + }.into() +} + + +fn generate_automatic_proxy_name(proxied_name: &Ident) -> Ident { + format_ident!("Lua{}",proxied_name) } + +/// Annotate a function with meta information relevant to proxy generation +fn generate_function_meta<'a>(proxy_name: &'a Ident ,name: &'a Ident, body: &'a TraitItemMethod) -> FunctionMeta<'a> { + // interpret and validate function meta to instantiate function proxies + let meta = body.attrs + .iter() + .find(|attr| attr.path.is_ident("lua")) + .unwrap_or_else(|| abort!(body, "Lua proxy functions require `lua` meta attribute like so: `#[lua()]`")) + .parse_meta() + .unwrap_or_else(|err| abort!(body, err)); + + match meta { + Meta::List(MetaList { nested, .. }) => { + + let mut fn_type = FunctionType::Function; + + nested + .iter() + .for_each(|attr|{ + if let NestedMeta::Meta(Meta::Path(p)) = attr { + let attr_str = p.get_ident().map(Ident::to_string).unwrap_or_default(); + if let Ok(_fn_type) = FunctionType::from_str(&attr_str) { + fn_type = _fn_type; + return; + } + } + + emit_error!(attr, "unknown or malformed lua proxy function attribute. Allowed attributes include: {}", + FunctionType::iterator() + .map(FunctionType::as_ident_str).collect::>().join(",")); + }); + + let fn_meta = FunctionMeta{ + name, + body, + fn_type, + arg_meta: body.sig.inputs.iter() + .map(|arg| (proxy_name, arg).into()) + .collect(), + }; + // validate the function against it's meta + fn_meta.validate_function_definition(body); + + fn_meta + }, + _ => abort!(body, "`lua` attribute must be a meta list of the form: `lua(elem1,elem2)`") + } +} \ No newline at end of file From aca39eaa5071331217e331d32bd598afd2267265 Mon Sep 17 00:00:00 2001 From: makspll Date: Sat, 27 May 2023 11:09:28 +0100 Subject: [PATCH 04/94] WIP --- .vscode/settings.json | 7 +- bevy_mod_scripting_common/src/input.rs | 1 + bevy_mod_scripting_common/src/utils.rs | 18 +- examples/wrappers.rs | 15 +- .../bevy_mod_scripting_lua_derive/src/lib.rs | 460 ++++++++++++------ 5 files changed, 329 insertions(+), 172 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 7ee5bcfb9b..e1b48f9947 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,5 +12,10 @@ ], "rust-analyzer.server.extraEnv": { "RUSTUP_TOOLCHAIN": "stable" - } + }, + "[rust]": { + "editor.formatOnSave": true, + "editor.formatOnSaveMode": "file", + "editor.defaultFormatter": "rust-lang.rust-analyzer" + }, } \ No newline at end of file diff --git a/bevy_mod_scripting_common/src/input.rs b/bevy_mod_scripting_common/src/input.rs index af9dbb6d4e..80ef138feb 100644 --- a/bevy_mod_scripting_common/src/input.rs +++ b/bevy_mod_scripting_common/src/input.rs @@ -156,6 +156,7 @@ impl TryFrom for ProxyMeta { .attrs .iter() .map(attribute_to_string_lit) + .filter(|s| !s.is_empty()) .collect(); let proxy_meta = derive_input diff --git a/bevy_mod_scripting_common/src/utils.rs b/bevy_mod_scripting_common/src/utils.rs index b7e2369af7..3ef2a7ea22 100644 --- a/bevy_mod_scripting_common/src/utils.rs +++ b/bevy_mod_scripting_common/src/utils.rs @@ -97,17 +97,31 @@ macro_rules! impl_parse_enum { } pub(crate) use impl_parse_enum; -use proc_macro2::TokenStream; +use proc_macro2::{Ident, TokenStream}; use quote::ToTokens; use syn::{ parse::{Parse, ParseStream}, - Attribute, Type, + Attribute, Path, PathArguments, PathSegment, Type, TypePath, }; pub fn attribute_to_string_lit(attrs: &Attribute) -> TokenStream { attrs.tokens.clone().into_iter().skip(1).collect() } +pub fn ident_to_type_path(ident: Ident) -> TypePath { + TypePath { + qself: None, + path: Path { + leading_colon: None, + segments: [PathSegment { + ident, + arguments: PathArguments::None, + }] + .into_iter() + .collect(), + }, + } +} /// Converts the given ToTokens into token stream, stringifies it and removes whitespace pub fn stringify_token_group(t: &T) -> String { let mut k = t.into_token_stream().to_string(); diff --git a/examples/wrappers.rs b/examples/wrappers.rs index 12ceb70f1b..beddd00151 100644 --- a/examples/wrappers.rs +++ b/examples/wrappers.rs @@ -23,19 +23,16 @@ pub struct MyThing { #[proxy(languages("on_feature(lua)"))] #[functions[ - // #[lua(MutatingMetaMethod)] - // fn basd(mut self) { - - // } - // #[lua(MetaMethod)] - // fn asd(self); - - #[lua(Method)] - fn basda(self); + #[lua(Function,output(proxy))] + fn basda(abc : String) -> Lol; ]] pub struct Lol {} +impl Lol { + pub fn basda(str: String) -> Self {} +} + impl MyThing { pub fn do_something_cool(&self) -> String { self.string.clone() diff --git a/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/languages/bevy_mod_scripting_lua_derive/src/lib.rs index 742ee58712..5b0ac704a3 100644 --- a/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -1,15 +1,20 @@ use bevy_mod_scripting_common::{ implementor::WrapperImplementor, input::{DeriveFlag, ProxyMeta}, - newtype::Newtype, utils::attribute_to_string_lit, + newtype::Newtype, + utils::{attribute_to_string_lit, ident_to_type_path}, }; use implementor::LuaImplementor; // use impls::{impl_enum, impl_struct}; use proc_macro::TokenStream; use proc_macro2::{Ident, Span}; -use proc_macro_error::{proc_macro_error, abort, emit_error}; -use quote::{quote_spanned, format_ident, quote, ToTokens}; -use syn::{parse_macro_input, DeriveInput, TraitItemMethod, MetaList, Meta, NestedMeta, Error, FnArg, spanned::Spanned, TypePath, parse_quote, PatType, Attribute, Lit, token::Mut}; +use proc_macro_error::{abort, emit_error, proc_macro_error}; +use quote::{format_ident, quote, quote_spanned, ToTokens}; +use syn::{ + parse_macro_input, parse_quote, punctuated::Punctuated, spanned::Spanned, token::Mut, + Attribute, DeriveInput, Error, FnArg, Lit, Meta, MetaList, NestedMeta, Pat, PatType, Path, + PathArguments, PathSegment, TraitItemMethod, Type, TypePath, +}; pub(crate) mod derive_flags; pub(crate) mod implementor; @@ -28,24 +33,24 @@ pub fn impl_lua_newtype(tokens: TokenStream) -> TokenStream { .into() } -struct FunctionArgMeta<'a> { - fn_arg: &'a FnArg, +const SELF_ALIAS: &str = "_self"; + +struct FunctionArgMeta { is_receiver: bool, is_a_lua_proxy: bool, mutable: Option, - /// the processed type path, for proxies outer references are stripped - type_path: TypePath, + /// the type of the argument, only suported patterns are allowed + arg_type: Type, arg_name: Ident, + span: Span, } -impl <'a>From<(&'a Ident,&'a FnArg)> for FunctionArgMeta<'a>{ - /// Parse function argument meta using the proxy type name and the actual syn::FnArg - /// type_path will be replaced with the proxy type name for receiver args - /// arguments which are annotated with #[proxy] and #[proxy("name")] attributes are resolved as proxies with the type path - /// resolving to their proxy name - fn from((proxy_name, fn_arg): (&'a Ident,&'a FnArg)) -> Self { +impl FunctionArgMeta { + /// Creates a new meta structure corresponding to the given function argument. + /// Resolves receivers with the given proxy name. + fn new_from_fn_arg(proxy_name: &Ident, fn_arg: &FnArg) -> Self { let is_a_lua_proxy; - let type_path; + let arg_type; let arg_name; let mutable; let is_receiver; @@ -53,7 +58,7 @@ impl <'a>From<(&'a Ident,&'a FnArg)> for FunctionArgMeta<'a>{ FnArg::Receiver(receiver) => { is_receiver = true; is_a_lua_proxy = true; - type_path = parse_quote!(#proxy_name); + arg_type = parse_quote!(#proxy_name); if let Some(_mut) = receiver.mutability { mutable = Some(_mut) @@ -61,11 +66,12 @@ impl <'a>From<(&'a Ident,&'a FnArg)> for FunctionArgMeta<'a>{ mutable = None } - arg_name = format_ident!("_self"); - }, - FnArg::Typed(PatType{ attrs, pat, ty , ..}) => { + arg_name = format_ident!("{}", SELF_ALIAS); + } + FnArg::Typed(PatType { attrs, pat, ty, .. }) => { is_receiver = false; - let proxy_attr = attrs.iter() + let proxy_attr = attrs + .iter() .find_map(|attr| attr.path.is_ident("proxy").then_some(attr)); is_a_lua_proxy = proxy_attr.is_some(); @@ -84,37 +90,216 @@ impl <'a>From<(&'a Ident,&'a FnArg)> for FunctionArgMeta<'a>{ Meta::NameValue(name_val) => abort!(name_val, "Expected single item attribute list containing proxy name as in: `proxy(\"proxy_name\")`") }); - if let Some(name) = passed_proxy_name { - type_path = parse_quote!(#name); + if let Some(name) = passed_proxy_name { + arg_type = Type::Path(ident_to_type_path(name)); } else { - type_path = parse_quote!(#ty); + arg_type = *ty.clone(); } arg_name = parse_quote!(#pat); - }, + } } FunctionArgMeta { - fn_arg, is_receiver, is_a_lua_proxy, mutable, - type_path, - arg_name + arg_type, + arg_name, + span: fn_arg.span(), } } + + /// Similar to [`Self::new_from_fn_arg`] but without an option of getting a receiver argument type + fn new_from_type( + proxy_name: &Ident, + arg_name: Ident, + arg_type: &Type, + attrs: Vec, + ) -> Self { + let ty = Box::new(arg_type.clone()); + let pat_ty = PatType { + attrs, + pat: parse_quote!(#arg_name), + colon_token: Default::default(), + ty, + }; + + Self::new_from_fn_arg(proxy_name, &FnArg::Typed(pat_ty)) + } } struct FunctionMeta<'a> { name: &'a Ident, body: &'a TraitItemMethod, fn_type: FunctionType, - arg_meta: Vec> + arg_meta: Vec, + output_meta: Option, } - impl FunctionMeta<'_> { + fn new<'a>( + proxy_name: &'a Ident, + name: &'a Ident, + body: &'a TraitItemMethod, + ) -> FunctionMeta<'a> { + // interpret and validate function meta to instantiate function proxies + let meta = body + .attrs + .iter() + .find(|attr| attr.path.is_ident("lua")) + .unwrap_or_else(|| { + abort!( + body, + "Lua proxy functions require `lua` meta attribute like so: `#[lua()]`" + ) + }) + .parse_meta() + .unwrap_or_else(|err| abort!(body, err)); + + let mut output_attrs = Vec::default(); + + match meta { + Meta::List(MetaList { nested, .. }) => { + let mut fn_type = FunctionType::Function; + + nested + .iter() + .for_each(|attr|{ + if let NestedMeta::Meta(Meta::Path(p)) = attr { + let attr_str = p.get_ident().map(Ident::to_string).unwrap_or_default(); + if let Ok(_fn_type) = FunctionType::from_str(&attr_str) { + fn_type = _fn_type; + return; + } + } else if let NestedMeta::Meta(Meta::List(list)) = attr { + if list.path.is_ident("output") { + for attr in list.nested.iter() { + output_attrs.push(parse_quote!(#[#attr])) + } + return; + } + } + + emit_error!(attr, "unknown or malformed lua proxy function attribute. Allowed attributes include: {}", + FunctionType::iterator() + .map(FunctionType::as_ident_str).collect::>().join(",")); + }); + + let fn_meta = FunctionMeta { + name, + body, + fn_type, + arg_meta: body + .sig + .inputs + .iter() + .map(|arg| FunctionArgMeta::new_from_fn_arg(proxy_name, arg)) + .collect(), + output_meta: match &body.sig.output { + syn::ReturnType::Default => None, + syn::ReturnType::Type(_, t) => Some(FunctionArgMeta::new_from_type( + proxy_name, + format_ident!("out"), + t, + output_attrs, + )), + }, + }; + // validate the function against it's meta + fn_meta.validate_function_definition(body); + + fn_meta + } + _ => abort!( + body, + "`lua` attribute must be a meta list of the form: `lua(elem1,elem2)`" + ), + } + } + + /// Converts the function's arguments into closure arguments for use in the closures given to mlua calls + /// + /// # Example + /// ```rust,ignore + /// // the function: + /// fn foo(self, my_str : String){} + /// // would convert to + /// // | _, my_proxy: MyLua, (my_str): (String) | + /// // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ <- these bits + /// ``` + fn generate_mlua_args(&self) -> proc_macro2::TokenStream { + let mut args = self.arg_meta.iter(); + + let mut self_arg = None; + if self.fn_type.expects_receiver() { + if let Some(meta) = args.next() { + let _mut = &meta.mutable; + let self_name = &meta.arg_name; + let self_type = &meta.arg_type; + self_arg = Some(quote_spanned!(meta.span=> , #self_name : & #_mut #self_type)); + } + } + + let (args, arg_types) = args + .map(|fn_arg| { + let _mut = &fn_arg.mutable; + let name = &fn_arg.arg_name; + let type_path = &fn_arg.arg_type; + ( + quote_spanned!(fn_arg.span=>#name ), + quote_spanned!(fn_arg.span=>#_mut #type_path), + ) + }) + .unzip::<_, _, Vec, Vec>(); + + quote_spanned!(self.body.sig.inputs.span()=>_ #self_arg , (#(#args),*) : (#(#arg_types),*)) + } + + fn generate_mlua_body(&self, proxied_name: &Ident) -> proc_macro2::TokenStream { + if let Some(body) = &self.body.default { + return body.to_token_stream(); + } + + let parameters = self.arg_meta.iter().map(|arg| { + let name = &arg.arg_name; + if arg.is_a_lua_proxy { + quote_spanned!(name.span()=>#name.inner()?) + } else { + quote_spanned!(name.span()=>#name) + } + }); + + let function_name = self.name; + + let inner_method_call = if self.fn_type.expects_receiver() { + let self_ident = format_ident!("{}", SELF_ALIAS); + + quote_spanned! {self.body.span()=> + #self_ident.inner()? + .#function_name(#(#parameters),*) + } + } else { + quote_spanned! {self.body.span()=> + #proxied_name::#function_name(#(#parameters),*) + } + }; + + if let Some(output_meta) = &self.output_meta { + if output_meta.is_a_lua_proxy { + let proxied_name = &output_meta.arg_type; + return quote_spanned! {self.body.span()=> + Ok(#proxied_name::new(#inner_method_call)) + }; + } + } + + quote_spanned!(self.body.span()=>Ok(#inner_method_call)) + } + + + fn validate_function_definition(&self, definition: &TraitItemMethod) { if self.fn_type.expects_receiver() { if let Some(FnArg::Receiver(receiver)) = definition.sig.receiver() { @@ -123,17 +308,28 @@ impl FunctionMeta<'_> { emit_error!(receiver, "Proxy receivers can only be one of: `self` or `mut self`, Proxies have pass by value semantics.") } if self.fn_type.expects_mutable_receiver() && receiver.mutability.is_none() { - emit_error!(receiver, format!("Lua proxy functions of type: {}, require `mut self` argument", self.fn_type.as_str())); + emit_error!( + receiver, + format!( + "Lua proxy functions of type: {}, require `mut self` argument", + self.fn_type.as_str() + ) + ); } } else { - emit_error!(definition, format!("Lua proxy functions of type: {}, require `self` argument", self.fn_type.as_str())) + emit_error!( + definition, + format!( + "Lua proxy functions of type: {}, require `self` argument", + self.fn_type.as_str() + ) + ) } } } } - -#[derive(PartialEq,Eq,Clone,Copy)] +#[derive(PartialEq, Eq, Clone, Copy)] enum FunctionType { Function, MetaFunction, @@ -159,7 +355,7 @@ impl FunctionType { } } - pub fn from_str(str: &str) -> Result { + pub fn from_str(str: &str) -> Result { match str { "Function" => Ok(FunctionType::Function), "MetaFunction" => Ok(FunctionType::MetaFunction), @@ -169,39 +365,40 @@ impl FunctionType { "MutableMetaFunction" => Ok(FunctionType::MutableMetaFunction), "MutatingMethod" => Ok(FunctionType::MutatingMethod), "MutatingMetaMethod" => Ok(FunctionType::MutatingMetaMethod), - _ => Err(()) + _ => Err(()), } } - pub fn as_ident_str(self) -> String { self.as_str().split_whitespace().collect() } - pub fn iterator() -> impl Iterator { - [FunctionType::Function, - FunctionType::Method, - FunctionType::MetaMethod, - FunctionType::MetaFunction, - FunctionType::MutableFunction, - FunctionType::MutatingMethod, - FunctionType::MutatingMetaMethod, - FunctionType::MutableMetaFunction].into_iter() + pub fn iterator() -> impl Iterator { + [ + FunctionType::Function, + FunctionType::Method, + FunctionType::MetaMethod, + FunctionType::MetaFunction, + FunctionType::MutableFunction, + FunctionType::MutatingMethod, + FunctionType::MutatingMetaMethod, + FunctionType::MutableMetaFunction, + ] + .into_iter() } fn expects_receiver(self) -> bool { - self == FunctionType::Method || - self == FunctionType::MetaMethod || - self == FunctionType::MutatingMethod || - self == FunctionType::MutatingMetaMethod + self == FunctionType::Method + || self == FunctionType::MetaMethod + || self == FunctionType::MutatingMethod + || self == FunctionType::MutatingMetaMethod } fn expects_mutable_receiver(self) -> bool { - self == FunctionType::MutatingMethod || - self == FunctionType::MutatingMetaMethod + self == FunctionType::MutatingMethod || self == FunctionType::MutatingMetaMethod } - fn get_tealr_function(self) -> &'static str{ + fn get_tealr_function(self) -> &'static str { match self { FunctionType::Function => "add_function", FunctionType::MetaFunction => "add_meta_function", @@ -215,12 +412,11 @@ impl FunctionType { } fn is_meta(self) -> bool { - self == FunctionType::MetaMethod || - self == FunctionType::MetaFunction || - self == FunctionType::MutatingMetaMethod || - self == FunctionType::MutableMetaFunction + self == FunctionType::MetaMethod + || self == FunctionType::MetaFunction + || self == FunctionType::MutatingMetaMethod + || self == FunctionType::MutableMetaFunction } - } #[proc_macro_error] @@ -233,12 +429,11 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { Err(err) => return err.to_compile_error().into(), }; - let proxy_name = - if meta.proxy_name == meta.proxied_name { - generate_automatic_proxy_name(&meta.proxy_name) - } else { - meta.proxy_name - }; + let proxy_name = if meta.proxy_name == meta.proxied_name { + generate_automatic_proxy_name(&meta.proxy_name) + } else { + meta.proxy_name + }; let proxied_name = meta.proxied_name; let is_clonable = meta.proxy_flags.flags.contains(&DeriveFlag::Clone); @@ -259,70 +454,63 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { definition.extend(quote_spanned!{meta.span=> impl std::fmt::Debug for #proxy_name { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { - self.val(|s| s.fmt(f)).unwrap_or_else(|_| f.write_str("Error while retrieving reference in `std::fmt::Debug`."))} - } + self.val(|s| s.fmt(f)).unwrap_or_else(|_| f.write_str("Error while retrieving reference in `std::fmt::Debug`."))} + } }); } - - let tealr_type_implementations = quote_spanned!{meta.span=> + + let tealr_type_implementations = quote_spanned! {meta.span=> bevy_script_api::impl_tealr_type!(#proxy_name); }; // generate type level tealr documentation calls - let type_level_document_calls = - meta.docstrings - .iter() - .map(|tkns| - quote_spanned!(meta.span=>methods.document_type(#tkns);)); - - // generate both tealr documentation and instantiations of functions - let methods = meta.functions + let type_level_document_calls = meta + .docstrings .iter() - .map(|(name, body)| { - - let method_documentation_calls = body.attrs.iter() - .map(attribute_to_string_lit) - .map(|ts| quote_spanned!(body.span()=>methods.document_type(#ts);)); - - let fn_meta = generate_function_meta(&proxy_name, name, body); - let tealr_function = format_ident!("{}",fn_meta.fn_type.get_tealr_function()); - let signature = fn_meta.fn_type - .is_meta() - .then(|| fn_meta.name.to_token_stream()) - .unwrap_or_else(|| fn_meta.name.to_string().to_token_stream()); - - let closure_args = fn_meta.arg_meta - .iter() - .map(|fn_arg| { - let _mut = &fn_arg.mutable; - let name = &fn_arg.arg_name; - let type_path = &fn_arg.type_path; - quote_spanned!(fn_arg.fn_arg.span()=>#_mut #name : #type_path) - }); - - let closure = quote_spanned!{body.span()=> - |_ #(, #closure_args)*| { - Ok(()) - } - }; - + .map(|tkns| quote_spanned!(meta.span=>methods.document_type(#tkns);)); - quote_spanned!{body.span()=> - #(#method_documentation_calls)* - methods.#tealr_function(#signature, #closure); + // generate both tealr documentation and instantiations of functions + let methods = meta.functions.iter().map(|(name, body)| { + let method_documentation_calls = body + .attrs + .iter() + .map(attribute_to_string_lit) + .filter(|s| !s.is_empty()) + .map(|ts| quote_spanned!(body.span()=>methods.document_type(#ts);)); + + let fn_meta = FunctionMeta::new(&proxy_name, name, body); + let args = fn_meta.generate_mlua_args(); + let body = fn_meta.generate_mlua_body(&proxied_name); + let closure = quote_spanned! {body.span()=> + |#args| { + #body } - }); - panic!("{}", methods.collect::()); + }; + panic!("{}", closure); + + let tealr_function = format_ident!("{}", fn_meta.fn_type.get_tealr_function()); + let signature = fn_meta + .fn_type + .is_meta() + .then(|| fn_meta.name.to_token_stream()) + .unwrap_or_else(|| fn_meta.name.to_string().to_token_stream()); + + quote_spanned! {body.span()=> + #(#method_documentation_calls)* + methods.#tealr_function(#signature, #closure); + } + }); let tealr = quote!(bevy_mod_scripting_lua::tealr); - quote_spanned!{meta.span=> + quote_spanned! {meta.span=> #definition #tealr_type_implementations #[automatically_derived] + #[allow(unused_parens)] impl #tealr::mlu::TealData for #proxy_name { fn add_methods<'lua, T: #tealr::mlu::TealDataMethods<'lua, Self>>(methods: &mut T) { #(#type_level_document_calls)* @@ -334,58 +522,10 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { } } - }.into() + } + .into() } - fn generate_automatic_proxy_name(proxied_name: &Ident) -> Ident { - format_ident!("Lua{}",proxied_name) + format_ident!("Lua{}", proxied_name) } - -/// Annotate a function with meta information relevant to proxy generation -fn generate_function_meta<'a>(proxy_name: &'a Ident ,name: &'a Ident, body: &'a TraitItemMethod) -> FunctionMeta<'a> { - // interpret and validate function meta to instantiate function proxies - let meta = body.attrs - .iter() - .find(|attr| attr.path.is_ident("lua")) - .unwrap_or_else(|| abort!(body, "Lua proxy functions require `lua` meta attribute like so: `#[lua()]`")) - .parse_meta() - .unwrap_or_else(|err| abort!(body, err)); - - match meta { - Meta::List(MetaList { nested, .. }) => { - - let mut fn_type = FunctionType::Function; - - nested - .iter() - .for_each(|attr|{ - if let NestedMeta::Meta(Meta::Path(p)) = attr { - let attr_str = p.get_ident().map(Ident::to_string).unwrap_or_default(); - if let Ok(_fn_type) = FunctionType::from_str(&attr_str) { - fn_type = _fn_type; - return; - } - } - - emit_error!(attr, "unknown or malformed lua proxy function attribute. Allowed attributes include: {}", - FunctionType::iterator() - .map(FunctionType::as_ident_str).collect::>().join(",")); - }); - - let fn_meta = FunctionMeta{ - name, - body, - fn_type, - arg_meta: body.sig.inputs.iter() - .map(|arg| (proxy_name, arg).into()) - .collect(), - }; - // validate the function against it's meta - fn_meta.validate_function_definition(body); - - fn_meta - }, - _ => abort!(body, "`lua` attribute must be a meta list of the form: `lua(elem1,elem2)`") - } -} \ No newline at end of file From 81571557b1fdd95006542cf0f9dcafbaa81f6aee Mon Sep 17 00:00:00 2001 From: makspll Date: Sat, 27 May 2023 12:39:35 +0100 Subject: [PATCH 05/94] WIP --- examples/wrappers.rs | 6 ++++-- languages/bevy_mod_scripting_lua_derive/src/lib.rs | 13 ++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/examples/wrappers.rs b/examples/wrappers.rs index beddd00151..4c7d644cdb 100644 --- a/examples/wrappers.rs +++ b/examples/wrappers.rs @@ -25,12 +25,14 @@ pub struct MyThing { #[lua(Function,output(proxy))] - fn basda(abc : String) -> Lol; + fn basda(#[proxy] abc : Lol) -> Lol; ]] pub struct Lol {} impl Lol { - pub fn basda(str: String) -> Self {} + pub fn basda(str: String) -> Self { + Self {} + } } impl MyThing { diff --git a/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/languages/bevy_mod_scripting_lua_derive/src/lib.rs index 5b0ac704a3..bfc5d6826b 100644 --- a/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -80,10 +80,11 @@ impl FunctionArgMeta { let passed_proxy_name = proxy_attr .map(|attr| attr.parse_meta().unwrap_or_else(|err| abort!(attr, err))) .map(|meta| match meta { - Meta::Path(_) => generate_automatic_proxy_name(proxy_name), + Meta::Path(_) => proxy_name.clone(), Meta::List(MetaList{ nested, .. }) => { if let Some(NestedMeta::Lit(Lit::Str(proxy_name))) = nested.first() { - return format_ident!("{}", proxy_name.token().to_string()) + let string = proxy_name.token().to_string(); + return format_ident!("{}", string[1..string.len()-1]) } abort!(nested, "Expected single item attribute list containing proxy name as in: `proxy(\"proxy_name\")`"); }, @@ -248,8 +249,8 @@ impl FunctionMeta<'_> { let name = &fn_arg.arg_name; let type_path = &fn_arg.arg_type; ( - quote_spanned!(fn_arg.span=>#name ), - quote_spanned!(fn_arg.span=>#_mut #type_path), + quote_spanned!(fn_arg.span=>#_mut #name ), + quote_spanned!(fn_arg.span=>#type_path), ) }) .unzip::<_, _, Vec, Vec>(); @@ -258,6 +259,7 @@ impl FunctionMeta<'_> { } fn generate_mlua_body(&self, proxied_name: &Ident) -> proc_macro2::TokenStream { + if let Some(body) = &self.body.default { return body.to_token_stream(); } @@ -486,7 +488,8 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { #body } }; - panic!("{}", closure); + + // panic!("{}", closure); let tealr_function = format_ident!("{}", fn_meta.fn_type.get_tealr_function()); let signature = fn_meta From b208579e85b3b33145e07afba66616d9671f8f5a Mon Sep 17 00:00:00 2001 From: makspll Date: Sat, 27 May 2023 22:15:58 +0100 Subject: [PATCH 06/94] WIP --- examples/wrappers.rs | 23 ++- .../bevy_mod_scripting_lua_derive/src/lib.rs | 131 ++++++++++++++---- 2 files changed, 123 insertions(+), 31 deletions(-) diff --git a/examples/wrappers.rs b/examples/wrappers.rs index 4c7d644cdb..ff381a572b 100644 --- a/examples/wrappers.rs +++ b/examples/wrappers.rs @@ -22,15 +22,32 @@ pub struct MyThing { #[derive(ScriptProxy, Reflect)] #[proxy(languages("on_feature(lua)"))] #[functions[ + #[lua(Function)] + fn fn_over_string_returning_string(a : String) -> String; + #[lua(Function)] + fn fn_over_string(a : String); - #[lua(Function,output(proxy))] - fn basda(#[proxy] abc : Lol) -> Lol; + #[lua(Method,output(proxy))] + fn fn_over_self_ref(&self) -> Lol; + + #[lua(MutatingMethod,output(proxy))] + fn fn_over_self_ref_mut(&mut self) -> Lol; ]] pub struct Lol {} impl Lol { - pub fn basda(str: String) -> Self { + pub fn fn_over_string(_: String) {} + + pub fn fn_over_string_returning_string(str_: String) -> String { + str_ + } + + pub fn fn_over_self_ref(&self) -> Self { + Self {} + } + + pub fn fn_over_self_ref_mut(&mut self) -> Self { Self {} } } diff --git a/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/languages/bevy_mod_scripting_lua_derive/src/lib.rs index bfc5d6826b..01cae0bd0d 100644 --- a/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -1,6 +1,6 @@ use bevy_mod_scripting_common::{ implementor::WrapperImplementor, - input::{DeriveFlag, ProxyMeta}, + input::{DeriveFlag, ProxyMeta, ProxyFlags}, newtype::Newtype, utils::{attribute_to_string_lit, ident_to_type_path}, }; @@ -13,7 +13,7 @@ use quote::{format_ident, quote, quote_spanned, ToTokens}; use syn::{ parse_macro_input, parse_quote, punctuated::Punctuated, spanned::Spanned, token::Mut, Attribute, DeriveInput, Error, FnArg, Lit, Meta, MetaList, NestedMeta, Pat, PatType, Path, - PathArguments, PathSegment, TraitItemMethod, Type, TypePath, + PathArguments, PathSegment, TraitItemMethod, Type, TypePath, PatIdent, }; pub(crate) mod derive_flags; @@ -35,8 +35,11 @@ pub fn impl_lua_newtype(tokens: TokenStream) -> TokenStream { const SELF_ALIAS: &str = "_self"; +#[derive(Debug)] struct FunctionArgMeta { is_receiver: bool, + is_ref: bool, + is_mut_ref: bool, is_a_lua_proxy: bool, mutable: Option, /// the type of the argument, only suported patterns are allowed @@ -54,6 +57,8 @@ impl FunctionArgMeta { let arg_name; let mutable; let is_receiver; + let is_ref; + let is_mut_ref; match fn_arg { FnArg::Receiver(receiver) => { is_receiver = true; @@ -65,6 +70,8 @@ impl FunctionArgMeta { } else { mutable = None } + is_ref = receiver.reference.is_some(); + is_mut_ref = receiver.mutability.is_some(); arg_name = format_ident!("{}", SELF_ALIAS); } @@ -97,7 +104,23 @@ impl FunctionArgMeta { arg_type = *ty.clone(); } - arg_name = parse_quote!(#pat); + match ty.as_ref() { + Type::Reference(t) => { + is_ref = true; + is_mut_ref = t.mutability.is_some(); + }, + _ => { + is_ref = false; + is_mut_ref = false; + }, + } + + arg_name = match pat.as_ref() { + Pat::Ident(pat_ident) => pat_ident.ident.clone(), + Pat::Wild(_) => abort!(pat, "Cannot use `_` as identifier for proxy function"), + _ => abort!(pat, "Unsupported parameter pattern"), + }; + } } @@ -108,6 +131,8 @@ impl FunctionArgMeta { arg_type, arg_name, span: fn_arg.span(), + is_ref, + is_mut_ref, } } @@ -121,7 +146,13 @@ impl FunctionArgMeta { let ty = Box::new(arg_type.clone()); let pat_ty = PatType { attrs, - pat: parse_quote!(#arg_name), + pat: Box::new(Pat::Ident(PatIdent{ + attrs:Vec::default(), + by_ref: None, + mutability: None, + ident: arg_name, + subpat: None }) + ), colon_token: Default::default(), ty, }; @@ -239,6 +270,7 @@ impl FunctionMeta<'_> { let _mut = &meta.mutable; let self_name = &meta.arg_name; let self_type = &meta.arg_type; + self_arg = Some(quote_spanned!(meta.span=> , #self_name : & #_mut #self_type)); } } @@ -264,40 +296,82 @@ impl FunctionMeta<'_> { return body.to_token_stream(); } - let parameters = self.arg_meta.iter().map(|arg| { + // unpack all parameters which need to be unpacked via `.inner` calls, turn the rest into + let mut unpacked_parameters = self.arg_meta.iter().map(|arg| { let name = &arg.arg_name; - if arg.is_a_lua_proxy { + + // if a parameter is to be passed by value we use inner (which requires Clone to be supported) + if arg.is_a_lua_proxy && !arg.is_ref { quote_spanned!(name.span()=>#name.inner()?) } else { + // otherwise we depend on a later step to `turn` #name into an identifier for a reference within + // the context of a closure quote_spanned!(name.span()=>#name) } }); - let function_name = self.name; + let proxied_function_name = self.name; - let inner_method_call = if self.fn_type.expects_receiver() { - let self_ident = format_ident!("{}", SELF_ALIAS); + let proxied_method_call = if self.fn_type.expects_receiver() { + // this removes the first argument taken to be the receiver from the iterator + let first_arg = unpacked_parameters.next().unwrap_or_else(|| abort!(self.name,"Proxied functions of the type: {} expect a receiver argument (i.e. self)", self.fn_type.as_str())); quote_spanned! {self.body.span()=> - #self_ident.inner()? - .#function_name(#(#parameters),*) + #first_arg.#proxied_function_name(#(#unpacked_parameters),*) } } else { quote_spanned! {self.body.span()=> - #proxied_name::#function_name(#(#parameters),*) + #proxied_name::#proxied_function_name(#(#unpacked_parameters),*) } }; - if let Some(output_meta) = &self.output_meta { - if output_meta.is_a_lua_proxy { + // if the output is also a proxied type, we need to wrap the result in a proxy + let constructor_wrapped_full_call= match &self.output_meta { + Some(output_meta) if output_meta.is_a_lua_proxy => { let proxied_name = &output_meta.arg_type; - return quote_spanned! {self.body.span()=> - Ok(#proxied_name::new(#inner_method_call)) - }; + let proxy_type = &output_meta.arg_type; + quote_spanned! {self.body.span()=> + let __output : #proxy_type = #proxied_name::new(#proxied_method_call); + Ok(__output) + } } - } - - quote_spanned!(self.body.span()=>Ok(#inner_method_call)) + Some(output_meta) => { + let output_type = &output_meta.arg_type; + quote_spanned!{self.body.span()=> + let __output : #output_type = #proxied_method_call; + Ok(__output) + } + }, + None => quote_spanned!{self.body.span()=> + let __output : () = #proxied_method_call; + Ok(__output) + } + }; + // panic!("{}", constructor_wrapped_full_call); + + // for every argument which is a reference, we need a separate sort of call, + // we cannot use `v.inner()` since this operates over values, we must use `val_mut` or `val` to get a reference to the wrapped + // structure for the duration of the call + let reference_unpacked_constructor_wrapped_full_call = self.arg_meta.iter() + .fold(constructor_wrapped_full_call, |acc, arg_meta| { + if arg_meta.is_ref { + let method_call = if arg_meta.is_mut_ref { + format_ident!("val_mut") + } else { + format_ident!("val") + }; + + let arg_name = &arg_meta.arg_name; + + quote_spanned!{arg_meta.span=>{ + #arg_name.#method_call(|#arg_name| {#acc})? + }} + } else { + acc + } + }); + + reference_unpacked_constructor_wrapped_full_call } @@ -306,14 +380,11 @@ impl FunctionMeta<'_> { if self.fn_type.expects_receiver() { if let Some(FnArg::Receiver(receiver)) = definition.sig.receiver() { // validate receiver - if receiver.reference.is_some() { - emit_error!(receiver, "Proxy receivers can only be one of: `self` or `mut self`, Proxies have pass by value semantics.") - } if self.fn_type.expects_mutable_receiver() && receiver.mutability.is_none() { emit_error!( receiver, format!( - "Lua proxy functions of type: {}, require `mut self` argument", + "Lua proxy functions of type: {}, require `mut self` or `&mut self` argument", self.fn_type.as_str() ) ); @@ -442,6 +513,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { // generate the type definition of the proxy let mut definition: proc_macro2::TokenStream; + if is_clonable { definition = quote_spanned! {meta.span=> bevy_script_api::make_script_wrapper!(#proxied_name as #proxy_name with Clone); @@ -469,7 +541,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { let type_level_document_calls = meta .docstrings .iter() - .map(|tkns| quote_spanned!(meta.span=>methods.document_type(#tkns);)); + .map(|tkns| quote_spanned!(tkns.span()=>methods.document_type(#tkns);)); // generate both tealr documentation and instantiations of functions let methods = meta.functions.iter().map(|(name, body)| { @@ -478,18 +550,19 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { .iter() .map(attribute_to_string_lit) .filter(|s| !s.is_empty()) - .map(|ts| quote_spanned!(body.span()=>methods.document_type(#ts);)); + .map(|tkns| quote_spanned!(tkns.span()=>methods.document_type(#tkns);)); + let fn_meta = FunctionMeta::new(&proxy_name, name, body); let args = fn_meta.generate_mlua_args(); let body = fn_meta.generate_mlua_body(&proxied_name); + let closure = quote_spanned! {body.span()=> |#args| { #body } }; - // panic!("{}", closure); let tealr_function = format_ident!("{}", fn_meta.fn_type.get_tealr_function()); let signature = fn_meta @@ -513,7 +586,9 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { #tealr_type_implementations #[automatically_derived] - #[allow(unused_parens)] + #[allow(unused_parens,unused_braces)] + #[allow(clippy::all)] + impl #tealr::mlu::TealData for #proxy_name { fn add_methods<'lua, T: #tealr::mlu::TealDataMethods<'lua, Self>>(methods: &mut T) { #(#type_level_document_calls)* From da66355cae92714e5792eda70c5d08cd8af944f3 Mon Sep 17 00:00:00 2001 From: makspll Date: Sun, 28 May 2023 12:16:41 +0100 Subject: [PATCH 07/94] WIP --- examples/wrappers.rs | 1 + .../bevy_mod_scripting_lua_derive/src/lib.rs | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/examples/wrappers.rs b/examples/wrappers.rs index ff381a572b..762047ef0d 100644 --- a/examples/wrappers.rs +++ b/examples/wrappers.rs @@ -22,6 +22,7 @@ pub struct MyThing { #[derive(ScriptProxy, Reflect)] #[proxy(languages("on_feature(lua)"))] #[functions[ + #[lua(Function)] fn fn_over_string_returning_string(a : String) -> String; diff --git a/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/languages/bevy_mod_scripting_lua_derive/src/lib.rs index 01cae0bd0d..86325141ce 100644 --- a/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -302,11 +302,11 @@ impl FunctionMeta<'_> { // if a parameter is to be passed by value we use inner (which requires Clone to be supported) if arg.is_a_lua_proxy && !arg.is_ref { - quote_spanned!(name.span()=>#name.inner()?) + quote!(#name.inner()?) } else { // otherwise we depend on a later step to `turn` #name into an identifier for a reference within // the context of a closure - quote_spanned!(name.span()=>#name) + quote!(#name) } }); @@ -316,11 +316,11 @@ impl FunctionMeta<'_> { // this removes the first argument taken to be the receiver from the iterator let first_arg = unpacked_parameters.next().unwrap_or_else(|| abort!(self.name,"Proxied functions of the type: {} expect a receiver argument (i.e. self)", self.fn_type.as_str())); - quote_spanned! {self.body.span()=> + quote! { #first_arg.#proxied_function_name(#(#unpacked_parameters),*) } } else { - quote_spanned! {self.body.span()=> + quote! { #proxied_name::#proxied_function_name(#(#unpacked_parameters),*) } }; @@ -363,7 +363,7 @@ impl FunctionMeta<'_> { let arg_name = &arg_meta.arg_name; - quote_spanned!{arg_meta.span=>{ + quote_spanned!{self.body.span()=>{ #arg_name.#method_call(|#arg_name| {#acc})? }} } else { @@ -372,6 +372,7 @@ impl FunctionMeta<'_> { }); reference_unpacked_constructor_wrapped_full_call + } @@ -388,7 +389,7 @@ impl FunctionMeta<'_> { self.fn_type.as_str() ) ); - } + }; } else { emit_error!( definition, @@ -541,7 +542,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { let type_level_document_calls = meta .docstrings .iter() - .map(|tkns| quote_spanned!(tkns.span()=>methods.document_type(#tkns);)); + .map(|tkns| quote_spanned!(meta.span=>methods.document_type(#tkns);)); // generate both tealr documentation and instantiations of functions let methods = meta.functions.iter().map(|(name, body)| { @@ -550,7 +551,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { .iter() .map(attribute_to_string_lit) .filter(|s| !s.is_empty()) - .map(|tkns| quote_spanned!(tkns.span()=>methods.document_type(#tkns);)); + .map(|tkns| quote_spanned!(body.span()=>methods.document_type(#tkns);)); let fn_meta = FunctionMeta::new(&proxy_name, name, body); From f81c4cf7bfe03378cd4c8e33db8e654c4cc2bfb8 Mon Sep 17 00:00:00 2001 From: makspll Date: Sun, 28 May 2023 12:29:34 +0100 Subject: [PATCH 08/94] fix spans --- examples/wrappers.rs | 2 +- languages/bevy_mod_scripting_lua_derive/src/lib.rs | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/examples/wrappers.rs b/examples/wrappers.rs index 762047ef0d..ea75f09509 100644 --- a/examples/wrappers.rs +++ b/examples/wrappers.rs @@ -24,7 +24,7 @@ pub struct MyThing { #[functions[ #[lua(Function)] - fn fn_over_string_returning_string(a : String) -> String; + fn fn_over_string_returning_string(a : String); #[lua(Function)] fn fn_over_string(a : String); diff --git a/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/languages/bevy_mod_scripting_lua_derive/src/lib.rs index 86325141ce..4583961f57 100644 --- a/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -292,6 +292,10 @@ impl FunctionMeta<'_> { fn generate_mlua_body(&self, proxied_name: &Ident) -> proc_macro2::TokenStream { + // override this span, as otherwise spans propagate weird + let mut proxied_name = proxied_name.clone(); + proxied_name.set_span(self.body.sig.ident.span()); + if let Some(body) = &self.body.default { return body.to_token_stream(); } @@ -302,11 +306,11 @@ impl FunctionMeta<'_> { // if a parameter is to be passed by value we use inner (which requires Clone to be supported) if arg.is_a_lua_proxy && !arg.is_ref { - quote!(#name.inner()?) + quote_spanned!(name.span()=> #name.inner()?) } else { // otherwise we depend on a later step to `turn` #name into an identifier for a reference within // the context of a closure - quote!(#name) + name.to_token_stream() } }); @@ -316,11 +320,11 @@ impl FunctionMeta<'_> { // this removes the first argument taken to be the receiver from the iterator let first_arg = unpacked_parameters.next().unwrap_or_else(|| abort!(self.name,"Proxied functions of the type: {} expect a receiver argument (i.e. self)", self.fn_type.as_str())); - quote! { + quote_spanned! {self.body.span()=> #first_arg.#proxied_function_name(#(#unpacked_parameters),*) } } else { - quote! { + quote_spanned! {self.body.span()=> #proxied_name::#proxied_function_name(#(#unpacked_parameters),*) } }; @@ -347,7 +351,6 @@ impl FunctionMeta<'_> { Ok(__output) } }; - // panic!("{}", constructor_wrapped_full_call); // for every argument which is a reference, we need a separate sort of call, // we cannot use `v.inner()` since this operates over values, we must use `val_mut` or `val` to get a reference to the wrapped From 2f07cff2c7c34c0bf4c605b5338447453b3dbc6f Mon Sep 17 00:00:00 2001 From: makspll Date: Mon, 29 May 2023 15:58:21 +0100 Subject: [PATCH 09/94] Clean up proxy/proxied name abstraction --- bevy_mod_scripting_common/src/input.rs | 134 ++++++++++++++---- examples/wrappers.rs | 12 +- .../bevy_mod_scripting_lua_derive/src/lib.rs | 78 ++++++---- 3 files changed, 168 insertions(+), 56 deletions(-) diff --git a/bevy_mod_scripting_common/src/input.rs b/bevy_mod_scripting_common/src/input.rs index 80ef138feb..65f7fc21c0 100644 --- a/bevy_mod_scripting_common/src/input.rs +++ b/bevy_mod_scripting_common/src/input.rs @@ -2,13 +2,13 @@ use std::collections::VecDeque; use indexmap::{IndexMap, IndexSet}; use proc_macro2::{Ident, Span}; -use quote::TokenStreamExt; +use quote::{format_ident, ToTokens, TokenStreamExt}; use syn::{ bracketed, parenthesized, parse::{Nothing, Parse, ParseBuffer}, punctuated::Punctuated, spanned::Spanned, - Attribute, DataStruct, DeriveInput, Fields, TraitItemMethod, + Attribute, DataStruct, DeriveInput, Fields, Meta, NestedMeta, TraitItemMethod, Type, }; use crate::utils::attribute_to_string_lit; @@ -72,7 +72,15 @@ impl TryFrom for DeriveFlag { type Error = syn::Error; fn try_from(value: syn::NestedMeta) -> Result { - todo!() + match value { + NestedMeta::Meta(Meta::Path(p)) if p.is_ident("Clone") => Ok(Self::Clone), + NestedMeta::Meta(Meta::Path(p)) if p.is_ident("Debug") => Ok(Self::Debug), + NestedMeta::Meta(Meta::Path(p)) if p.is_ident("Display") => Ok(Self::Display), + _ => Err(syn::Error::new_spanned( + value, + "Expected one of `Debug`, `Display`, `Clone`", + )), + } } } @@ -120,6 +128,79 @@ pub enum ProxyData { Struct { fields: Fields }, } +pub struct ProxyTypeNameMeta { + proxied_type: Type, + proxied_type_ident: Ident, + proxy_type_ident: Ident, +} + +impl ProxyTypeNameMeta { + pub fn new(proxied_type: Type, proxy_prefix: &'static str) -> Self { + let proxied_type_ident = match &proxied_type { + Type::Path(p) if p.path.get_ident().is_some() => p.path.get_ident().unwrap().clone(), + _ => panic!( + "Expected identifier for proxied type, instead got: {}", + proxied_type.to_token_stream() + ), + }; + + Self { + proxy_type_ident: Self::proxy_type_to_ident( + proxy_prefix, + &proxied_type, + &proxied_type_ident, + ) + .unwrap(), + proxied_type_ident, + proxied_type, + } + } + + pub fn get_proxied_type_identifier(&self) -> &Ident { + &self.proxied_type_ident + } + + pub fn get_proxy_type_identifier(&self) -> &Ident { + &self.proxy_type_ident + } + + pub fn get_proxied_type(&self) -> &Type { + &self.proxied_type + } + + /// Converts a type representing a proxy (simple type with possible outer reference) without generics + /// into the identifier representing the type. in addition, replaces Self and self occurences with the given ident + /// uses `generate_automatic_proxy_name` in the case that the identifier is anything but `self` or `Self`. + /// + /// For example, `MyType` will be translated to `LuaMyType` if given the "Lua" prefix + /// `Self` will be translated to the proxied_type_identifier with the given prefix + /// etc. + pub fn proxy_type_to_ident( + proxy_prefix: &'static str, + proxy_type: &Type, + proxied_type_identifier: &Ident, + ) -> Result { + match proxy_type { + Type::Path(p) if p.path.is_ident("self") || p.path.is_ident("Self") => Ok( + format_ident!("{}{}", proxy_prefix, proxied_type_identifier.clone()), + ), + Type::Path(p) if p.path.get_ident().is_some() => Ok(format_ident!( + "{}{}", + proxy_prefix, + p.path.get_ident().unwrap() + )), + Type::Reference(tr) => { + Self::proxy_type_to_ident(proxy_prefix, &tr.elem, proxied_type_identifier) + } + _ => Err(( + proxy_type.span(), + "Expected simple type with one identifier and possible reference for proxy type" + .to_string(), + )), + } + } +} + /// Attributes relating to the proxy as a whole #[derive(Debug)] pub struct ProxyMeta { @@ -190,33 +271,38 @@ impl TryFrom for ProxyMeta { })?; let mut language_meta = Default::default(); - let proxy_flags = Default::default(); + let mut proxy_flags: ProxyFlags = Default::default(); if let syn::Meta::List(list) = proxy_meta { for attr in list.nested.into_iter() { - if let syn::NestedMeta::Meta(syn::Meta::NameValue(pair)) = attr { - let ident = pair.path.get_ident().ok_or_else(|| { - syn::Error::new_spanned(&pair, "Keys must be identifiers") - })?; - - match (ident.to_string().as_str(), pair.lit) { - ("name", syn::Lit::Str(_str)) => { - proxy_name = Ident::new(&_str.value(), _str.span()) + match attr { + NestedMeta::Meta(Meta::NameValue(pair)) => { + let ident = pair.path.get_ident().ok_or_else(|| { + syn::Error::new_spanned(&pair, "Keys must be identifiers") + })?; + + match (ident.to_string().as_str(), pair.lit) { + ("name", syn::Lit::Str(_str)) => { + proxy_name = Ident::new(&_str.value(), _str.span()) + } + _ => { + return Err(syn::Error::new_spanned(ident, "Unrecognized argument")) + } } - _ => return Err(syn::Error::new_spanned(ident, "Unrecognized argument")), } - } else if let syn::NestedMeta::Meta(syn::Meta::List(list)) = attr { - let ident = list - .path - .get_ident() - .ok_or_else(|| syn::Error::new_spanned(&list, "Expected identifier"))?; - - match ident.to_string().as_str() { - "languages" => language_meta = list.try_into()?, - _ => return Err(syn::Error::new_spanned(list, "")), + NestedMeta::Meta(Meta::List(list)) => { + let ident = list + .path + .get_ident() + .ok_or_else(|| syn::Error::new_spanned(&list, "Expected identifier"))?; + + match ident.to_string().as_str() { + "languages" => language_meta = list.try_into()?, + "derive" => proxy_flags = list.try_into()?, + _ => return Err(syn::Error::new_spanned(list, "")), + } } - } else { - return Err(syn::Error::new_spanned(attr, "Expected key value pair")); + _ => return Err(syn::Error::new_spanned(attr, "Expected key value pair")), } } } else { diff --git a/examples/wrappers.rs b/examples/wrappers.rs index ea75f09509..3af61068bd 100644 --- a/examples/wrappers.rs +++ b/examples/wrappers.rs @@ -20,11 +20,14 @@ pub struct MyThing { } #[derive(ScriptProxy, Reflect)] -#[proxy(languages("on_feature(lua)"))] +#[proxy(languages("on_feature(lua)"), derive(Clone))] #[functions[ + #[lua(Method,output(proxy))] + fn fn_over_self_and_another(self, #[proxy] another: &Self) -> Self; + #[lua(Function)] - fn fn_over_string_returning_string(a : String); + fn fn_over_string_returning_string(a : String) -> String; #[lua(Function)] fn fn_over_string(a : String); @@ -35,9 +38,14 @@ pub struct MyThing { #[lua(MutatingMethod,output(proxy))] fn fn_over_self_ref_mut(&mut self) -> Lol; ]] +#[derive(Clone)] pub struct Lol {} impl Lol { + pub fn fn_over_self_and_another(self, another: &Self) -> Self { + Self {} + } + pub fn fn_over_string(_: String) {} pub fn fn_over_string_returning_string(str_: String) -> String { diff --git a/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/languages/bevy_mod_scripting_lua_derive/src/lib.rs index 4583961f57..25923477dd 100644 --- a/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -1,6 +1,8 @@ +use std::borrow::Cow; + use bevy_mod_scripting_common::{ implementor::WrapperImplementor, - input::{DeriveFlag, ProxyMeta, ProxyFlags}, + input::{DeriveFlag, ProxyMeta, ProxyFlags, ProxyTypeNameMeta}, newtype::Newtype, utils::{attribute_to_string_lit, ident_to_type_path}, }; @@ -34,6 +36,7 @@ pub fn impl_lua_newtype(tokens: TokenStream) -> TokenStream { } const SELF_ALIAS: &str = "_self"; +const PROXY_PREFIX: &str = "Lua"; #[derive(Debug)] struct FunctionArgMeta { @@ -51,7 +54,7 @@ struct FunctionArgMeta { impl FunctionArgMeta { /// Creates a new meta structure corresponding to the given function argument. /// Resolves receivers with the given proxy name. - fn new_from_fn_arg(proxy_name: &Ident, fn_arg: &FnArg) -> Self { + fn new_from_fn_arg(proxy_type_name_meta: &ProxyTypeNameMeta, fn_arg: &FnArg) -> Self { let is_a_lua_proxy; let arg_type; let arg_name; @@ -63,7 +66,7 @@ impl FunctionArgMeta { FnArg::Receiver(receiver) => { is_receiver = true; is_a_lua_proxy = true; - arg_type = parse_quote!(#proxy_name); + arg_type = Type::Path(TypePath{ qself: None, path: proxy_type_name_meta.get_proxy_type_identifier().clone().into()}); if let Some(_mut) = receiver.mutability { mutable = Some(_mut) @@ -87,7 +90,9 @@ impl FunctionArgMeta { let passed_proxy_name = proxy_attr .map(|attr| attr.parse_meta().unwrap_or_else(|err| abort!(attr, err))) .map(|meta| match meta { - Meta::Path(_) => proxy_name.clone(), + Meta::Path(_) => { + ProxyTypeNameMeta::proxy_type_to_ident(PROXY_PREFIX,ty,proxy_type_name_meta.get_proxied_type_identifier()).unwrap_or_else(|(span,err)| abort!(span,err)) + }, Meta::List(MetaList{ nested, .. }) => { if let Some(NestedMeta::Lit(Lit::Str(proxy_name))) = nested.first() { let string = proxy_name.token().to_string(); @@ -138,11 +143,12 @@ impl FunctionArgMeta { /// Similar to [`Self::new_from_fn_arg`] but without an option of getting a receiver argument type fn new_from_type( - proxy_name: &Ident, + proxy_type_name_meta: &ProxyTypeNameMeta, arg_name: Ident, arg_type: &Type, attrs: Vec, ) -> Self { + let ty = Box::new(arg_type.clone()); let pat_ty = PatType { attrs, @@ -157,10 +163,19 @@ impl FunctionArgMeta { ty, }; - Self::new_from_fn_arg(proxy_name, &FnArg::Typed(pat_ty)) + + Self::new_from_fn_arg(proxy_type_name_meta, &FnArg::Typed(pat_ty)) + } + + pub fn get_type_stripped_from_outer_references(&self) -> &Type { + match &self.arg_type { + Type::Reference(r) => &r.elem, + _ => &self.arg_type, + } } } +#[derive(Debug)] struct FunctionMeta<'a> { name: &'a Ident, body: &'a TraitItemMethod, @@ -172,7 +187,7 @@ struct FunctionMeta<'a> { impl FunctionMeta<'_> { fn new<'a>( - proxy_name: &'a Ident, + proxy_type_name_meta: &ProxyTypeNameMeta, name: &'a Ident, body: &'a TraitItemMethod, ) -> FunctionMeta<'a> { @@ -218,7 +233,6 @@ impl FunctionMeta<'_> { FunctionType::iterator() .map(FunctionType::as_ident_str).collect::>().join(",")); }); - let fn_meta = FunctionMeta { name, body, @@ -227,12 +241,12 @@ impl FunctionMeta<'_> { .sig .inputs .iter() - .map(|arg| FunctionArgMeta::new_from_fn_arg(proxy_name, arg)) + .map(|arg| FunctionArgMeta::new_from_fn_arg(proxy_type_name_meta, arg)) .collect(), output_meta: match &body.sig.output { syn::ReturnType::Default => None, syn::ReturnType::Type(_, t) => Some(FunctionArgMeta::new_from_type( - proxy_name, + proxy_type_name_meta, format_ident!("out"), t, output_attrs, @@ -279,7 +293,15 @@ impl FunctionMeta<'_> { .map(|fn_arg| { let _mut = &fn_arg.mutable; let name = &fn_arg.arg_name; - let type_path = &fn_arg.arg_type; + + // strip outer refs if the type is a proxy, we cannot have any references in type position + // we can still have reference semantics since we have a proxy object which we pass by value + let type_path = if fn_arg.is_a_lua_proxy { + fn_arg.get_type_stripped_from_outer_references() + } else { + &fn_arg.arg_type + }; + ( quote_spanned!(fn_arg.span=>#_mut #name ), quote_spanned!(fn_arg.span=>#type_path), @@ -332,10 +354,9 @@ impl FunctionMeta<'_> { // if the output is also a proxied type, we need to wrap the result in a proxy let constructor_wrapped_full_call= match &self.output_meta { Some(output_meta) if output_meta.is_a_lua_proxy => { - let proxied_name = &output_meta.arg_type; let proxy_type = &output_meta.arg_type; quote_spanned! {self.body.span()=> - let __output : #proxy_type = #proxied_name::new(#proxied_method_call); + let __output : #proxy_type = #proxy_type::new(#proxied_method_call); Ok(__output) } } @@ -406,7 +427,7 @@ impl FunctionMeta<'_> { } } -#[derive(PartialEq, Eq, Clone, Copy)] +#[derive(PartialEq, Eq, Clone, Copy, Debug)] enum FunctionType { Function, MetaFunction, @@ -506,11 +527,12 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { Err(err) => return err.to_compile_error().into(), }; - let proxy_name = if meta.proxy_name == meta.proxied_name { - generate_automatic_proxy_name(&meta.proxy_name) - } else { - meta.proxy_name - }; + let proxy_type_name_meta = ProxyTypeNameMeta::new( + Type::Path(TypePath{ qself: None, path: meta.proxy_name.into() }), + PROXY_PREFIX + ); + + let proxy_identifier = proxy_type_name_meta.get_proxy_type_identifier(); let proxied_name = meta.proxied_name; let is_clonable = meta.proxy_flags.flags.contains(&DeriveFlag::Clone); @@ -520,17 +542,17 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { if is_clonable { definition = quote_spanned! {meta.span=> - bevy_script_api::make_script_wrapper!(#proxied_name as #proxy_name with Clone); + bevy_script_api::make_script_wrapper!(#proxied_name as #proxy_identifier with Clone); }; } else { definition = quote_spanned! {meta.span=> - bevy_script_api::make_script_wrapper!(#proxied_name as #proxy_name); + bevy_script_api::make_script_wrapper!(#proxied_name as #proxy_identifier); } } if meta.proxy_flags.flags.contains(&DeriveFlag::Debug) { definition.extend(quote_spanned!{meta.span=> - impl std::fmt::Debug for #proxy_name { + impl std::fmt::Debug for #proxy_identifier { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { self.val(|s| s.fmt(f)).unwrap_or_else(|_| f.write_str("Error while retrieving reference in `std::fmt::Debug`."))} } @@ -538,7 +560,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { } let tealr_type_implementations = quote_spanned! {meta.span=> - bevy_script_api::impl_tealr_type!(#proxy_name); + bevy_script_api::impl_tealr_type!(#proxy_identifier); }; // generate type level tealr documentation calls @@ -557,17 +579,15 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { .map(|tkns| quote_spanned!(body.span()=>methods.document_type(#tkns);)); - let fn_meta = FunctionMeta::new(&proxy_name, name, body); + let fn_meta = FunctionMeta::new(&proxy_type_name_meta, name, body); let args = fn_meta.generate_mlua_args(); let body = fn_meta.generate_mlua_body(&proxied_name); - let closure = quote_spanned! {body.span()=> |#args| { #body } }; - let tealr_function = format_ident!("{}", fn_meta.fn_type.get_tealr_function()); let signature = fn_meta .fn_type @@ -593,7 +613,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { #[allow(unused_parens,unused_braces)] #[allow(clippy::all)] - impl #tealr::mlu::TealData for #proxy_name { + impl #tealr::mlu::TealData for #proxy_identifier { fn add_methods<'lua, T: #tealr::mlu::TealDataMethods<'lua, Self>>(methods: &mut T) { #(#type_level_document_calls)* #(#methods)* @@ -608,6 +628,4 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { .into() } -fn generate_automatic_proxy_name(proxied_name: &Ident) -> Ident { - format_ident!("Lua{}", proxied_name) -} + From 7a4c7ac92acb93acab677a7d8f6b7627542d6050 Mon Sep 17 00:00:00 2001 From: makspll Date: Sat, 3 Jun 2023 23:39:41 +0100 Subject: [PATCH 10/94] add custom bodies with automatic unwrapping --- examples/wrappers.rs | 5 +++ .../bevy_mod_scripting_lua_derive/src/lib.rs | 44 ++++++++++++------- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/examples/wrappers.rs b/examples/wrappers.rs index 3af61068bd..fe9c2eab05 100644 --- a/examples/wrappers.rs +++ b/examples/wrappers.rs @@ -23,6 +23,11 @@ pub struct MyThing { #[proxy(languages("on_feature(lua)"), derive(Clone))] #[functions[ + #[lua(Method, output(proxy))] + fn custom_body(self, string: String) -> Self { + Lol{} + } + #[lua(Method,output(proxy))] fn fn_over_self_and_another(self, #[proxy] another: &Self) -> Self; diff --git a/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/languages/bevy_mod_scripting_lua_derive/src/lib.rs index 25923477dd..d62a4d726f 100644 --- a/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -318,10 +318,6 @@ impl FunctionMeta<'_> { let mut proxied_name = proxied_name.clone(); proxied_name.set_span(self.body.sig.ident.span()); - if let Some(body) = &self.body.default { - return body.to_token_stream(); - } - // unpack all parameters which need to be unpacked via `.inner` calls, turn the rest into let mut unpacked_parameters = self.arg_meta.iter().map(|arg| { let name = &arg.arg_name; @@ -338,19 +334,38 @@ impl FunctionMeta<'_> { let proxied_function_name = self.name; - let proxied_method_call = if self.fn_type.expects_receiver() { - // this removes the first argument taken to be the receiver from the iterator - let first_arg = unpacked_parameters.next().unwrap_or_else(|| abort!(self.name,"Proxied functions of the type: {} expect a receiver argument (i.e. self)", self.fn_type.as_str())); + let proxied_method_call = + match (self.fn_type.expects_receiver(),&self.body.default){ + (_, Some(body)) => { + let param_names = self.arg_meta.iter().map(|arg| &arg.arg_name); + let stmts = body.stmts.iter(); + + quote_spanned!{body.span()=> + { + #(let #param_names = #unpacked_parameters;)* + (||{ + #(#stmts)* + })() + } + } + }, + (true, None) => { + // this removes the first argument taken to be the receiver from the iterator for the next step + let first_arg = unpacked_parameters.next().unwrap_or_else(|| abort!(self.name,"Proxied functions of the type: {} expect a receiver argument (i.e. self)", self.fn_type.as_str())); - quote_spanned! {self.body.span()=> - #first_arg.#proxied_function_name(#(#unpacked_parameters),*) - } - } else { - quote_spanned! {self.body.span()=> - #proxied_name::#proxied_function_name(#(#unpacked_parameters),*) - } + // since we removed the receiver we can pass the rest of the parameters here; + quote_spanned! {self.body.span()=> + #first_arg.#proxied_function_name(#(#unpacked_parameters),*) + } + }, + (false, None) => { + quote_spanned! {self.body.span()=> + #proxied_name::#proxied_function_name(#(#unpacked_parameters),*) + } + }, }; + // if the output is also a proxied type, we need to wrap the result in a proxy let constructor_wrapped_full_call= match &self.output_meta { Some(output_meta) if output_meta.is_a_lua_proxy => { @@ -394,7 +409,6 @@ impl FunctionMeta<'_> { acc } }); - reference_unpacked_constructor_wrapped_full_call } From a29c7c52658aa377c375e733d630a91a920bb522 Mon Sep 17 00:00:00 2001 From: makspll Date: Mon, 5 Jun 2023 20:53:37 +0100 Subject: [PATCH 11/94] Implement support for custom bodies in wrapper only functions --- bevy_mod_scripting_common/Cargo.toml | 2 +- bevy_mod_scripting_common/src/input.rs | 23 ++++++++++++++--- examples/wrappers.rs | 25 +++++++++++++------ .../bevy_mod_scripting_lua_derive/src/lib.rs | 16 +++++++----- 4 files changed, 48 insertions(+), 18 deletions(-) diff --git a/bevy_mod_scripting_common/Cargo.toml b/bevy_mod_scripting_common/Cargo.toml index e1d08e48b8..5d3b366f64 100644 --- a/bevy_mod_scripting_common/Cargo.toml +++ b/bevy_mod_scripting_common/Cargo.toml @@ -22,7 +22,7 @@ path = "src/lib.rs" [dependencies] paste = "1.0.7" -syn = {version="1.0.57",features=["full","fold","extra-traits"]} +syn = {version="1.0.57",features=["full","fold","extra-traits", "visit-mut"]} quote = "1.0.8" proc-macro2 = "1.0" convert_case = "0.5.0" diff --git a/bevy_mod_scripting_common/src/input.rs b/bevy_mod_scripting_common/src/input.rs index 65f7fc21c0..6c4132367e 100644 --- a/bevy_mod_scripting_common/src/input.rs +++ b/bevy_mod_scripting_common/src/input.rs @@ -2,13 +2,13 @@ use std::collections::VecDeque; use indexmap::{IndexMap, IndexSet}; use proc_macro2::{Ident, Span}; -use quote::{format_ident, ToTokens, TokenStreamExt}; +use quote::{format_ident, ToTokens}; use syn::{ - bracketed, parenthesized, - parse::{Nothing, Parse, ParseBuffer}, + parse::{Nothing, Parse}, punctuated::Punctuated, spanned::Spanned, - Attribute, DataStruct, DeriveInput, Fields, Meta, NestedMeta, TraitItemMethod, Type, + visit_mut::VisitMut, + DataStruct, DeriveInput, Fields, Meta, NestedMeta, TraitItemMethod, Type, }; use crate::utils::attribute_to_string_lit; @@ -336,3 +336,18 @@ impl TryFrom for ProxyMeta { }) } } + +/// Replaces every occurence of an identifier with +/// the given string while preserving the original span +pub struct IdentifierRenamingVisitor<'a> { + pub target: &'a str, + pub replacement: &'a str, +} + +impl VisitMut for IdentifierRenamingVisitor<'_> { + fn visit_ident_mut(&mut self, i: &mut Ident) { + if *i == self.target { + *i = Ident::new(self.replacement, i.span()); + } + } +} diff --git a/examples/wrappers.rs b/examples/wrappers.rs index fe9c2eab05..75e487a727 100644 --- a/examples/wrappers.rs +++ b/examples/wrappers.rs @@ -24,11 +24,14 @@ pub struct MyThing { #[functions[ #[lua(Method, output(proxy))] - fn custom_body(self, string: String) -> Self { - Lol{} + fn custom_body(self) -> Self { + let a = self.some_string; + Lol{ + some_string: a + } } - #[lua(Method,output(proxy))] + #[lua(Method, output(proxy))] fn fn_over_self_and_another(self, #[proxy] another: &Self) -> Self; #[lua(Function)] @@ -44,11 +47,15 @@ pub struct MyThing { fn fn_over_self_ref_mut(&mut self) -> Lol; ]] #[derive(Clone)] -pub struct Lol {} +pub struct Lol { + some_string: String, +} impl Lol { pub fn fn_over_self_and_another(self, another: &Self) -> Self { - Self {} + Self { + some_string: "lol".to_owned(), + } } pub fn fn_over_string(_: String) {} @@ -58,11 +65,15 @@ impl Lol { } pub fn fn_over_self_ref(&self) -> Self { - Self {} + Self { + some_string: "lol".to_owned(), + } } pub fn fn_over_self_ref_mut(&mut self) -> Self { - Self {} + Self { + some_string: "lol".to_owned(), + } } } diff --git a/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/languages/bevy_mod_scripting_lua_derive/src/lib.rs index d62a4d726f..36a53819eb 100644 --- a/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -1,8 +1,6 @@ -use std::borrow::Cow; - use bevy_mod_scripting_common::{ implementor::WrapperImplementor, - input::{DeriveFlag, ProxyMeta, ProxyFlags, ProxyTypeNameMeta}, + input::{DeriveFlag, ProxyMeta, ProxyTypeNameMeta, IdentifierRenamingVisitor}, newtype::Newtype, utils::{attribute_to_string_lit, ident_to_type_path}, }; @@ -15,8 +13,7 @@ use quote::{format_ident, quote, quote_spanned, ToTokens}; use syn::{ parse_macro_input, parse_quote, punctuated::Punctuated, spanned::Spanned, token::Mut, Attribute, DeriveInput, Error, FnArg, Lit, Meta, MetaList, NestedMeta, Pat, PatType, Path, - PathArguments, PathSegment, TraitItemMethod, Type, TypePath, PatIdent, -}; + PathArguments, PathSegment, TraitItemMethod, Type, TypePath, PatIdent, visit_mut::VisitMut}; pub(crate) mod derive_flags; pub(crate) mod implementor; @@ -338,8 +335,15 @@ impl FunctionMeta<'_> { match (self.fn_type.expects_receiver(),&self.body.default){ (_, Some(body)) => { let param_names = self.arg_meta.iter().map(|arg| &arg.arg_name); - let stmts = body.stmts.iter(); + let stmts = body.stmts.iter().cloned().map(|mut s| { + IdentifierRenamingVisitor{ + target: "self", + replacement: SELF_ALIAS, + }.visit_stmt_mut(&mut s); + s + }); + quote_spanned!{body.span()=> { #(let #param_names = #unpacked_parameters;)* From a754b6fc8ebc0a79eb626e0ed97ce595608f6404 Mon Sep 17 00:00:00 2001 From: makspll Date: Fri, 16 Jun 2023 00:58:41 +0100 Subject: [PATCH 12/94] some refactoring + Option support --- bevy_mod_scripting_common/src/input.rs | 330 ++++++++++++++---- examples/wrappers.rs | 13 + .../bevy_mod_scripting_lua_derive/src/lib.rs | 297 +++++++++------- 3 files changed, 463 insertions(+), 177 deletions(-) diff --git a/bevy_mod_scripting_common/src/input.rs b/bevy_mod_scripting_common/src/input.rs index 6c4132367e..590b32bade 100644 --- a/bevy_mod_scripting_common/src/input.rs +++ b/bevy_mod_scripting_common/src/input.rs @@ -5,13 +5,17 @@ use proc_macro2::{Ident, Span}; use quote::{format_ident, ToTokens}; use syn::{ parse::{Nothing, Parse}, + parse_quote, punctuated::Punctuated, spanned::Spanned, + token::{And, Colon2, Gt, Lt, Mut}, visit_mut::VisitMut, - DataStruct, DeriveInput, Fields, Meta, NestedMeta, TraitItemMethod, Type, + AngleBracketedGenericArguments, DataStruct, DeriveInput, Fields, GenericArgument, Meta, + NestedMeta, PatType, Path, PathArguments, PathSegment, Receiver, Token, TraitItemMethod, Type, + TypePath, TypeReference, TypeTuple, }; -use crate::utils::attribute_to_string_lit; +use crate::utils::{attribute_to_string_lit, ident_to_type_path}; /// Convenience structure for holding data relevant to proxy generation pub struct DeriveMeta {} @@ -128,77 +132,283 @@ pub enum ProxyData { Struct { fields: Fields }, } -pub struct ProxyTypeNameMeta { - proxied_type: Type, - proxied_type_ident: Ident, - proxy_type_ident: Ident, +/// For types of the form `Option` i.e. an outer identifier with a nested type inside angle brackets. +/// This type helps us destructure these patterns and unwrap/wrap proxies fully without dealing with the complicated full syn::Type enum +#[derive(Debug, Clone)] +pub struct UnitPath { + pub ident: Ident, + pub colon2_token: Option, + pub lt_token: Lt, + pub gt_token: Gt, + pub inner: Box, } -impl ProxyTypeNameMeta { - pub fn new(proxied_type: Type, proxy_prefix: &'static str) -> Self { - let proxied_type_ident = match &proxied_type { - Type::Path(p) if p.path.get_ident().is_some() => p.path.get_ident().unwrap().clone(), - _ => panic!( - "Expected identifier for proxied type, instead got: {}", - proxied_type.to_token_stream() - ), - }; +/// Represents a type prefixed with an outer reference, e.g. `&T` or `&mut T` +#[derive(Debug, Clone)] +pub struct Reference { + pub and_token: And, + pub mutability: Option, + pub inner: Box, +} - Self { - proxy_type_ident: Self::proxy_type_to_ident( - proxy_prefix, - &proxied_type, - &proxied_type_ident, - ) - .unwrap(), - proxied_type_ident, - proxied_type, - } - } +/// Represents the identifier part of a type which doubles as a proxy type, e.g. `T` in `Option` +/// Stores both the proxied and proxy identifier i.e. `T` and `LuaT` +#[derive(Debug, Clone)] +pub struct ProxyType { + pub proxied_ident: Ident, + pub proxy_ident: Ident, +} - pub fn get_proxied_type_identifier(&self) -> &Ident { - &self.proxied_type_ident - } +/// Proxies can also be returned in "container" types, such as: +/// - Option +/// - Result +/// - Vec +/// - Tuple +/// This type helps us destructure these patterns and unwrap/wrap proxies fully without dealing with the full syn::Type enum +#[derive(Debug, Clone)] +pub enum SimpleType { + /// The unit type `()` + Unit, + /// A type of the form `Option` + UnitPath(UnitPath), + /// A type with an outer reference, e.g. `&T` or `&mut T` + Reference(Reference), + /// A type which doubles as a proxy type, e.g. `T` in `Option` + ProxyType(ProxyType), + /// A type which is not a proxy type, e.g. `i32`, required for composite types which can contain both proxy and non-proxy types + /// like tuples: `(i32, T)` + Type(syn::Type), +} - pub fn get_proxy_type_identifier(&self) -> &Ident { - &self.proxy_type_ident +impl SimpleType { + /// Constructs a new SimpleProxyType from a `syn::FnArg` using contextual resolution for receivers such as `Self` and `self` with the proxied type identifier given. + pub fn new_from_fn_arg( + proxy_prefix: &'static str, + arg: &syn::FnArg, + proxied_type_identifier: &Ident, + ) -> Result { + match arg { + syn::FnArg::Receiver(Receiver { + reference, + mutability, + .. + }) => match reference { + Some((and, ..)) => { + let mutability = mutability.as_ref().copied(); + let inner = Box::new(SimpleType::new_from_contextual_type( + proxy_prefix, + &Type::Path(ident_to_type_path(proxied_type_identifier.clone())), + proxied_type_identifier, + )?); + Ok(Self::Reference(Reference { + and_token: *and, + mutability, + inner, + })) + } + None => Self::new_from_contextual_type( + proxy_prefix, + &Type::Path(ident_to_type_path(proxied_type_identifier.clone())), + proxied_type_identifier, + ), + }, + syn::FnArg::Typed(PatType { ty, .. }) => { + Self::new_from_contextual_type(proxy_prefix, ty.as_ref(), proxied_type_identifier) + } + } } - pub fn get_proxied_type(&self) -> &Type { - &self.proxied_type + /// Constructs a new SimpleProxyType from a `syn::Type`, contextual receivers such as `Self` and `self` will cause an error + /// to be returned. + pub fn new_from_fully_specified_type( + proxy_prefix: &'static str, + proxied_type: &Type, + ) -> Result { + Self::new_from_type(proxy_prefix, proxied_type, None) } - /// Converts a type representing a proxy (simple type with possible outer reference) without generics - /// into the identifier representing the type. in addition, replaces Self and self occurences with the given ident - /// uses `generate_automatic_proxy_name` in the case that the identifier is anything but `self` or `Self`. - /// - /// For example, `MyType` will be translated to `LuaMyType` if given the "Lua" prefix - /// `Self` will be translated to the proxied_type_identifier with the given prefix - /// etc. - pub fn proxy_type_to_ident( + /// Constructs a new SimpleProxyType from a `syn::Type`, contextual receivers such as `Self` and `self` will be replaced + /// with the given identifier prefixed with the proxy_prefix + pub fn new_from_contextual_type( proxy_prefix: &'static str, - proxy_type: &Type, + proxied_type: &Type, proxied_type_identifier: &Ident, - ) -> Result { - match proxy_type { - Type::Path(p) if p.path.is_ident("self") || p.path.is_ident("Self") => Ok( - format_ident!("{}{}", proxy_prefix, proxied_type_identifier.clone()), - ), - Type::Path(p) if p.path.get_ident().is_some() => Ok(format_ident!( - "{}{}", - proxy_prefix, - p.path.get_ident().unwrap() - )), - Type::Reference(tr) => { - Self::proxy_type_to_ident(proxy_prefix, &tr.elem, proxied_type_identifier) + ) -> Result { + Self::new_from_type(proxy_prefix, proxied_type, Some(proxied_type_identifier)) + } + + /// Constructs a new SimpleProxyType from a `syn::Type`, if `proxied_type_identifier` is given then contextual + /// receivers such as `Self` and `self` will be replaced with the given identifier prefixed with the proxy_prefix, otherwise an error will be returned. + fn new_from_type( + proxy_prefix: &'static str, + proxied_type: &Type, + proxied_type_identifier: Option<&Ident>, + ) -> Result { + match proxied_type { + Type::Path(p) if p.path.is_ident("self") || p.path.is_ident("Self") => { + let proxied_ident = proxied_type_identifier.ok_or_else(|| { + ( + proxied_type.span(), + "Did not expect contextual receiver in constructing simple proxy type" + .to_owned(), + ) + })?; + + Ok(SimpleType::ProxyType(ProxyType { + proxied_ident: proxied_ident.clone(), + proxy_ident: format_ident!("{}{}", proxy_prefix, proxied_ident), + })) } + Type::Path(p) if !p.path.segments.is_empty() => { + let last_segment = p.path.segments.last().unwrap(); + if last_segment.arguments.is_empty() { + return Ok(SimpleType::ProxyType(ProxyType { + proxied_ident: last_segment.ident.clone(), + proxy_ident: format_ident!("{}{}", proxy_prefix, last_segment.ident), + })); + } else if let PathArguments::AngleBracketed(args) = &last_segment.arguments { + if args.args.len() == 1 { + if let GenericArgument::Type(arg_type) = args.args.first().unwrap() { + let inner = Box::new(Self::new_from_type( + proxy_prefix, + arg_type, + proxied_type_identifier, + )?); + return Ok(SimpleType::UnitPath(UnitPath { + ident: last_segment.ident.clone(), + colon2_token: args.colon2_token, + lt_token: args.lt_token, + gt_token: args.gt_token, + inner, + })); + } + } + } + Err((proxied_type.span(), "Unsupported type".to_owned())) + } + Type::Reference(tr) => Ok(SimpleType::Reference(Reference { + and_token: tr.and_token, + mutability: tr.mutability, + inner: Box::new(Self::new_from_type( + proxy_prefix, + &tr.elem, + proxied_type_identifier, + )?), + })), + Type::Tuple(TypeTuple { elems , ..}) if elems.is_empty() => { + Ok(SimpleType::Unit) + }, _ => Err(( - proxy_type.span(), - "Expected simple type with one identifier and possible reference for proxy type" - .to_string(), + proxied_type.span(), + format!("Expected simple type with one identifier and possible reference for proxy type, got {}", proxied_type.to_token_stream()), )), } } + + /// Returns true if the type has an outer reference, (e.g. `&Type`) + pub fn has_outer_ref(&self) -> bool { + matches!(self, SimpleType::Reference { .. }) + } + + pub fn has_outer_mut_ref(&self) -> bool { + matches!(self, SimpleType::Reference (Reference{ mutability, .. }) if mutability.is_some()) + } + + /// Strips outer references and returns the type if any are present + pub fn construct_proxy_type_without_outer_ref(&self) -> Type { + match self { + SimpleType::Reference(Reference { inner, .. }) => inner.construct_proxy_type(), + other => other.construct_proxy_type(), + } + } + + /// Constructs a syn::Type from this SimpleProxyType, representing the proxied type + pub fn construct_proxied_type(&self) -> Type { + self.construct_type_with_proxy_conversion(|proxied_ident, _| { + Type::Path(ident_to_type_path(proxied_ident.clone())) + }) + } + + /// Constructs a syn::Type from this SimpleProxyType, representing the proxy type + pub fn construct_proxy_type(&self) -> Type { + self.construct_type_with_proxy_conversion(|_, proxy_ident| { + Type::Path(ident_to_type_path(proxy_ident.clone())) + }) + } + + /// A helper function for constructing a syn::Type from this SimpleProxyType, using the given function to convert + /// the proxied type identifier and proxy type identifier into a syn::Type + fn construct_type_with_proxy_conversion Type>( + &self, + proxy_conversion: F, + ) -> Type { + match self { + SimpleType::UnitPath(UnitPath { + ident, + colon2_token, + lt_token, + gt_token, + inner, + }) => Type::Path(TypePath { + qself: None, + path: PathSegment { + ident: ident.clone(), + arguments: PathArguments::AngleBracketed(AngleBracketedGenericArguments { + colon2_token: *colon2_token, + lt_token: *lt_token, + args: Punctuated::from_iter( + [GenericArgument::Type( + inner.construct_type_with_proxy_conversion(proxy_conversion), + )] + .into_iter(), + ), + gt_token: *gt_token, + }), + } + .into(), + }), + SimpleType::Reference(Reference { + and_token, + mutability, + inner, + }) => Type::Reference(TypeReference { + and_token: *and_token, + lifetime: None, + mutability: *mutability, + elem: Box::new(inner.construct_type_with_proxy_conversion(proxy_conversion)), + }), + SimpleType::Unit => Type::Tuple(TypeTuple { + paren_token: Default::default(), + elems: Default::default(), + }), + SimpleType::Type(_) => todo!(), + SimpleType::ProxyType(ProxyType { + proxied_ident, + proxy_ident, + }) => proxy_conversion(proxied_ident, proxy_ident), + } + } +} + +pub trait VisitSimpleType { + fn visit_simple_type(&self, simple_type: &SimpleType) -> T { + match simple_type { + SimpleType::Unit => self.visit_unit(), + SimpleType::UnitPath(unit_path) => self.visit_unit_path(unit_path), + SimpleType::Reference(reference) => self.visit_reference(reference), + SimpleType::ProxyType(proxy_type) => self.visit_proxy_type(proxy_type), + SimpleType::Type(_type) => self.visit_type(_type), + } + } + fn visit_unit_path(&self, unit_path: &UnitPath) -> T { + self.visit_simple_type(&unit_path.inner) + } + fn visit_reference(&self, reference: &Reference) -> T { + self.visit_simple_type(&reference.inner) + } + fn visit_unit(&self) -> T; + fn visit_proxy_type(&self, proxy_type: &ProxyType) -> T; + fn visit_type(&self, _type: &Type) -> T; } /// Attributes relating to the proxy as a whole @@ -207,7 +417,7 @@ pub struct ProxyMeta { /// the identifier of the proxied type pub proxied_name: Ident, /// the identifier for the proxy type - pub proxy_name: Ident, + pub proxy_name: Option, /// language derivation settings pub language_meta: LanguageMeta, /// additional flags for the proxy @@ -226,7 +436,7 @@ impl TryFrom for ProxyMeta { type Error = syn::Error; fn try_from(derive_input: DeriveInput) -> Result { - let mut proxy_name = derive_input.ident.clone(); + let mut proxy_name = None; let span = derive_input.span(); // helper for collecting errors which are not fatal to the logic flow @@ -283,7 +493,7 @@ impl TryFrom for ProxyMeta { match (ident.to_string().as_str(), pair.lit) { ("name", syn::Lit::Str(_str)) => { - proxy_name = Ident::new(&_str.value(), _str.span()) + proxy_name = Some(Ident::new(&_str.value(), _str.span())) } _ => { return Err(syn::Error::new_spanned(ident, "Unrecognized argument")) diff --git a/examples/wrappers.rs b/examples/wrappers.rs index 75e487a727..6bd0fdcdfa 100644 --- a/examples/wrappers.rs +++ b/examples/wrappers.rs @@ -23,6 +23,15 @@ pub struct MyThing { #[proxy(languages("on_feature(lua)"), derive(Clone))] #[functions[ + #[lua(Method, output(proxy))] + fn fn_returning_option(self) -> Option:: { + let a = self.some_string; + Some(Lol{ + some_string: a + }) + } + + #[lua(Method, output(proxy))] fn custom_body(self) -> Self { let a = self.some_string; @@ -52,6 +61,10 @@ pub struct Lol { } impl Lol { + pub fn fn_returning_option(self) -> Option { + Some(self) + } + pub fn fn_over_self_and_another(self, another: &Self) -> Self { Self { some_string: "lol".to_owned(), diff --git a/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/languages/bevy_mod_scripting_lua_derive/src/lib.rs index 36a53819eb..71b479c7fc 100644 --- a/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -1,6 +1,8 @@ +use std::borrow::Cow; + use bevy_mod_scripting_common::{ implementor::WrapperImplementor, - input::{DeriveFlag, ProxyMeta, ProxyTypeNameMeta, IdentifierRenamingVisitor}, + input::{DeriveFlag, ProxyMeta, IdentifierRenamingVisitor, SimpleType, UnitPath, ProxyType, VisitSimpleType}, newtype::Newtype, utils::{attribute_to_string_lit, ident_to_type_path}, }; @@ -11,9 +13,9 @@ use proc_macro2::{Ident, Span}; use proc_macro_error::{abort, emit_error, proc_macro_error}; use quote::{format_ident, quote, quote_spanned, ToTokens}; use syn::{ - parse_macro_input, parse_quote, punctuated::Punctuated, spanned::Spanned, token::Mut, + parse_macro_input, parse_quote, punctuated::Punctuated, spanned::Spanned, token::{Mut, Paren}, Attribute, DeriveInput, Error, FnArg, Lit, Meta, MetaList, NestedMeta, Pat, PatType, Path, - PathArguments, PathSegment, TraitItemMethod, Type, TypePath, PatIdent, visit_mut::VisitMut}; + PathArguments, PathSegment, TraitItemMethod, Type, TypePath, PatIdent, visit_mut::VisitMut, TypeTuple, ReturnType}; pub(crate) mod derive_flags; pub(crate) mod implementor; @@ -33,89 +35,72 @@ pub fn impl_lua_newtype(tokens: TokenStream) -> TokenStream { } const SELF_ALIAS: &str = "_self"; +const OUT_ALIAS: &str = "__out"; const PROXY_PREFIX: &str = "Lua"; +/// categorises and provides meta data about the broad categories of function arguments/ outputs which are +/// handled by the macro +#[derive(Debug)] +enum ArgVariant { + NonProxy{ + arg_type: Type, + }, + Proxy{ + proxy_type: SimpleType, + }, +} + #[derive(Debug)] struct FunctionArgMeta { - is_receiver: bool, - is_ref: bool, - is_mut_ref: bool, - is_a_lua_proxy: bool, mutable: Option, /// the type of the argument, only suported patterns are allowed - arg_type: Type, arg_name: Ident, span: Span, + /// variant specific data enumeration + variant_data: ArgVariant, } impl FunctionArgMeta { /// Creates a new meta structure corresponding to the given function argument. /// Resolves receivers with the given proxy name. - fn new_from_fn_arg(proxy_type_name_meta: &ProxyTypeNameMeta, fn_arg: &FnArg) -> Self { - let is_a_lua_proxy; - let arg_type; + fn new_from_fn_arg(simple_type: &SimpleType, fn_arg: &FnArg) -> Self { let arg_name; let mutable; - let is_receiver; - let is_ref; - let is_mut_ref; + let variant_data; + match fn_arg { FnArg::Receiver(receiver) => { - is_receiver = true; - is_a_lua_proxy = true; - arg_type = Type::Path(TypePath{ qself: None, path: proxy_type_name_meta.get_proxy_type_identifier().clone().into()}); + variant_data = ArgVariant::Proxy { proxy_type: simple_type.clone() }; if let Some(_mut) = receiver.mutability { mutable = Some(_mut) } else { mutable = None } - is_ref = receiver.reference.is_some(); - is_mut_ref = receiver.mutability.is_some(); arg_name = format_ident!("{}", SELF_ALIAS); } FnArg::Typed(PatType { attrs, pat, ty, .. }) => { - is_receiver = false; let proxy_attr = attrs .iter() .find_map(|attr| attr.path.is_ident("proxy").then_some(attr)); - is_a_lua_proxy = proxy_attr.is_some(); mutable = proxy_attr.is_some().then(|| parse_quote!(mut)); - let passed_proxy_name = proxy_attr + let passed_proxy_type = proxy_attr .map(|attr| attr.parse_meta().unwrap_or_else(|err| abort!(attr, err))) .map(|meta| match meta { - Meta::Path(_) => { - ProxyTypeNameMeta::proxy_type_to_ident(PROXY_PREFIX,ty,proxy_type_name_meta.get_proxied_type_identifier()).unwrap_or_else(|(span,err)| abort!(span,err)) - }, - Meta::List(MetaList{ nested, .. }) => { - if let Some(NestedMeta::Lit(Lit::Str(proxy_name))) = nested.first() { - let string = proxy_name.token().to_string(); - return format_ident!("{}", string[1..string.len()-1]) - } - abort!(nested, "Expected single item attribute list containing proxy name as in: `proxy(\"proxy_name\")`"); - }, - Meta::NameValue(name_val) => abort!(name_val, "Expected single item attribute list containing proxy name as in: `proxy(\"proxy_name\")`") + // #[proxy] + Meta::Path(_) => simple_type.clone(), + other => abort!(other.span(), "Expected single item attribute list containing proxy name as in: `proxy(\"proxy_name\")`") }); - if let Some(name) = passed_proxy_name { - arg_type = Type::Path(ident_to_type_path(name)); + if let Some(proxy_type) = passed_proxy_type { + variant_data = ArgVariant::Proxy { proxy_type } } else { - arg_type = *ty.clone(); + variant_data = ArgVariant::NonProxy { arg_type: *ty.clone()} } - match ty.as_ref() { - Type::Reference(t) => { - is_ref = true; - is_mut_ref = t.mutability.is_some(); - }, - _ => { - is_ref = false; - is_mut_ref = false; - }, - } arg_name = match pat.as_ref() { Pat::Ident(pat_ident) => pat_ident.ident.clone(), @@ -127,25 +112,20 @@ impl FunctionArgMeta { } FunctionArgMeta { - is_receiver, - is_a_lua_proxy, mutable, - arg_type, arg_name, span: fn_arg.span(), - is_ref, - is_mut_ref, + variant_data, } } /// Similar to [`Self::new_from_fn_arg`] but without an option of getting a receiver argument type fn new_from_type( - proxy_type_name_meta: &ProxyTypeNameMeta, + simple_type: &SimpleType, arg_name: Ident, arg_type: &Type, attrs: Vec, ) -> Self { - let ty = Box::new(arg_type.clone()); let pat_ty = PatType { attrs, @@ -161,15 +141,25 @@ impl FunctionArgMeta { }; - Self::new_from_fn_arg(proxy_type_name_meta, &FnArg::Typed(pat_ty)) + Self::new_from_fn_arg(simple_type, &FnArg::Typed(pat_ty)) } - pub fn get_type_stripped_from_outer_references(&self) -> &Type { - match &self.arg_type { - Type::Reference(r) => &r.elem, - _ => &self.arg_type, + /// Unpacks non-reference proxy parameters (using the `inner` method) yielding expressions which correspond to the proxied type with conversion errors being + /// handled by the try `?` operator. + pub fn unpack_parameter(&self) -> proc_macro2::TokenStream { + let name = &self.arg_name; + + // if a proxy parameter is to be passed by value we use inner (which requires Clone to be supported) + if matches!(&self.variant_data, ArgVariant::Proxy{proxy_type} if !proxy_type.has_outer_ref()) { + quote_spanned!(name.span()=> #name.inner()?) + } else { + // if the parameter is not a proxy or a reference + // we do not call anything as .inner() + name.to_token_stream() } } + + } #[derive(Debug)] @@ -178,13 +168,13 @@ struct FunctionMeta<'a> { body: &'a TraitItemMethod, fn_type: FunctionType, arg_meta: Vec, - output_meta: Option, + output_meta: FunctionArgMeta, } impl FunctionMeta<'_> { fn new<'a>( - proxy_type_name_meta: &ProxyTypeNameMeta, + proxied_type_identifier: Ident, name: &'a Ident, body: &'a TraitItemMethod, ) -> FunctionMeta<'a> { @@ -230,6 +220,13 @@ impl FunctionMeta<'_> { FunctionType::iterator() .map(FunctionType::as_ident_str).collect::>().join(",")); }); + + // if no output type is specified, it's set to the unit type `()` + let output_type = match &body.sig.output { + ReturnType::Default => Type::Tuple(TypeTuple{ paren_token: Paren::default(), elems: Punctuated::default() }), + ReturnType::Type(_, t) => *t.to_owned(), + }; + let fn_meta = FunctionMeta { name, body, @@ -238,17 +235,16 @@ impl FunctionMeta<'_> { .sig .inputs .iter() - .map(|arg| FunctionArgMeta::new_from_fn_arg(proxy_type_name_meta, arg)) + .map(|arg| (SimpleType::new_from_fn_arg(PROXY_PREFIX, arg, &proxied_type_identifier).unwrap_or_else(|(s,e)| abort!(s,e)), arg)) + .map(|(simple_type,arg)| FunctionArgMeta::new_from_fn_arg(&simple_type, arg)) .collect(), - output_meta: match &body.sig.output { - syn::ReturnType::Default => None, - syn::ReturnType::Type(_, t) => Some(FunctionArgMeta::new_from_type( - proxy_type_name_meta, - format_ident!("out"), - t, + output_meta: FunctionArgMeta::new_from_type( + &SimpleType::new_from_contextual_type(PROXY_PREFIX, &output_type, &proxied_type_identifier).unwrap_or_else(|(s,e)| abort!(s,e)), + format_ident!("{OUT_ALIAS}"), + &output_type, output_attrs, - )), - }, + ) + , }; // validate the function against it's meta fn_meta.validate_function_definition(body); @@ -280,7 +276,10 @@ impl FunctionMeta<'_> { if let Some(meta) = args.next() { let _mut = &meta.mutable; let self_name = &meta.arg_name; - let self_type = &meta.arg_type; + let self_type = match &meta.variant_data { + ArgVariant::Proxy { proxy_type } => proxy_type.construct_proxy_type_without_outer_ref(), + ArgVariant::NonProxy { arg_type } => abort!(arg_type, "Function expects a receiver type as first argument which needs to be a proxy type") , + }; self_arg = Some(quote_spanned!(meta.span=> , #self_name : & #_mut #self_type)); } @@ -292,15 +291,14 @@ impl FunctionMeta<'_> { let name = &fn_arg.arg_name; // strip outer refs if the type is a proxy, we cannot have any references in type position - // we can still have reference semantics since we have a proxy object which we pass by value - let type_path = if fn_arg.is_a_lua_proxy { - fn_arg.get_type_stripped_from_outer_references() - } else { - &fn_arg.arg_type + // we can still have reference semantics since we have a proxy object, however we still pass it by value + let type_path = match &fn_arg.variant_data { + ArgVariant::Proxy { proxy_type } => proxy_type.construct_proxy_type_without_outer_ref(), + ArgVariant::NonProxy { arg_type } => arg_type.clone() }; ( - quote_spanned!(fn_arg.span=>#_mut #name ), + quote_spanned!(fn_arg.span=>#_mut #name), quote_spanned!(fn_arg.span=>#type_path), ) }) @@ -315,21 +313,12 @@ impl FunctionMeta<'_> { let mut proxied_name = proxied_name.clone(); proxied_name.set_span(self.body.sig.ident.span()); - // unpack all parameters which need to be unpacked via `.inner` calls, turn the rest into - let mut unpacked_parameters = self.arg_meta.iter().map(|arg| { - let name = &arg.arg_name; - - // if a parameter is to be passed by value we use inner (which requires Clone to be supported) - if arg.is_a_lua_proxy && !arg.is_ref { - quote_spanned!(name.span()=> #name.inner()?) - } else { - // otherwise we depend on a later step to `turn` #name into an identifier for a reference within - // the context of a closure - name.to_token_stream() - } - }); + // unpack all parameters which need to be unpacked via `.inner` calls, we deal with reference proxies later + let mut unpacked_parameters = self.arg_meta + .iter() + .map(FunctionArgMeta::unpack_parameter); - let proxied_function_name = self.name; + let function_name = self.name; let proxied_method_call = match (self.fn_type.expects_receiver(),&self.body.default){ @@ -359,36 +348,40 @@ impl FunctionMeta<'_> { // since we removed the receiver we can pass the rest of the parameters here; quote_spanned! {self.body.span()=> - #first_arg.#proxied_function_name(#(#unpacked_parameters),*) + #first_arg.#function_name(#(#unpacked_parameters),*) } }, (false, None) => { quote_spanned! {self.body.span()=> - #proxied_name::#proxied_function_name(#(#unpacked_parameters),*) + #proxied_name::#function_name(#(#unpacked_parameters),*) } }, }; // if the output is also a proxied type, we need to wrap the result in a proxy - let constructor_wrapped_full_call= match &self.output_meta { - Some(output_meta) if output_meta.is_a_lua_proxy => { - let proxy_type = &output_meta.arg_type; + let constructor_wrapped_full_call= match &self.output_meta.variant_data { + ArgVariant::Proxy{proxy_type} => { + let out_ident = format_ident!("{OUT_ALIAS}"); + + let constructor_wrapped_expression = ProxyMapVisitor{ arg_name: out_ident.clone(), span: self.body.span() }.visit_simple_type(proxy_type); + + // the type before we wrap it in a proxy + let proxied_output_type = proxy_type.construct_proxied_type(); + // the type after we wrap it in a proxy + let output_type = proxy_type.construct_proxy_type(); + quote_spanned! {self.body.span()=> - let __output : #proxy_type = #proxy_type::new(#proxied_method_call); + let #out_ident : #proxied_output_type = #proxied_method_call; + let __output : #output_type = #constructor_wrapped_expression; Ok(__output) } } - Some(output_meta) => { - let output_type = &output_meta.arg_type; + ArgVariant::NonProxy{ arg_type } => { quote_spanned!{self.body.span()=> - let __output : #output_type = #proxied_method_call; + let __output : #arg_type = #proxied_method_call; Ok(__output) } - }, - None => quote_spanned!{self.body.span()=> - let __output : () = #proxied_method_call; - Ok(__output) } }; @@ -397,8 +390,12 @@ impl FunctionMeta<'_> { // structure for the duration of the call let reference_unpacked_constructor_wrapped_full_call = self.arg_meta.iter() .fold(constructor_wrapped_full_call, |acc, arg_meta| { - if arg_meta.is_ref { - let method_call = if arg_meta.is_mut_ref { + if let ArgVariant::Proxy{proxy_type} = &arg_meta.variant_data { + if !proxy_type.has_outer_ref(){ + return acc; + } + + let method_call = if proxy_type.has_outer_mut_ref() { format_ident!("val_mut") } else { format_ident!("val") @@ -545,14 +542,18 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { Err(err) => return err.to_compile_error().into(), }; - let proxy_type_name_meta = ProxyTypeNameMeta::new( - Type::Path(TypePath{ qself: None, path: meta.proxy_name.into() }), - PROXY_PREFIX - ); - - let proxy_identifier = proxy_type_name_meta.get_proxy_type_identifier(); + if meta.proxy_name.is_some() { + // throw error + abort!( + meta.span, + "The `proxy_name` attribute is not supported for lua proxies" + ); + } let proxied_name = meta.proxied_name; + + let proxy_type = Type::Path(TypePath{ qself: None, path: format_ident!("{PROXY_PREFIX}{}",proxied_name).into() }); + let is_clonable = meta.proxy_flags.flags.contains(&DeriveFlag::Clone); // generate the type definition of the proxy @@ -560,17 +561,17 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { if is_clonable { definition = quote_spanned! {meta.span=> - bevy_script_api::make_script_wrapper!(#proxied_name as #proxy_identifier with Clone); + bevy_script_api::make_script_wrapper!(#proxied_name as #proxy_type with Clone); }; } else { definition = quote_spanned! {meta.span=> - bevy_script_api::make_script_wrapper!(#proxied_name as #proxy_identifier); + bevy_script_api::make_script_wrapper!(#proxied_name as #proxy_type); } } if meta.proxy_flags.flags.contains(&DeriveFlag::Debug) { definition.extend(quote_spanned!{meta.span=> - impl std::fmt::Debug for #proxy_identifier { + impl std::fmt::Debug for #proxy_type { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { self.val(|s| s.fmt(f)).unwrap_or_else(|_| f.write_str("Error while retrieving reference in `std::fmt::Debug`."))} } @@ -578,7 +579,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { } let tealr_type_implementations = quote_spanned! {meta.span=> - bevy_script_api::impl_tealr_type!(#proxy_identifier); + bevy_script_api::impl_tealr_type!(#proxy_type); }; // generate type level tealr documentation calls @@ -597,7 +598,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { .map(|tkns| quote_spanned!(body.span()=>methods.document_type(#tkns);)); - let fn_meta = FunctionMeta::new(&proxy_type_name_meta, name, body); + let fn_meta = FunctionMeta::new(proxied_name.clone(), name, body); let args = fn_meta.generate_mlua_args(); let body = fn_meta.generate_mlua_body(&proxied_name); let closure = quote_spanned! {body.span()=> @@ -631,7 +632,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { #[allow(unused_parens,unused_braces)] #[allow(clippy::all)] - impl #tealr::mlu::TealData for #proxy_identifier { + impl #tealr::mlu::TealData for #proxy_type { fn add_methods<'lua, T: #tealr::mlu::TealDataMethods<'lua, Self>>(methods: &mut T) { #(#type_level_document_calls)* #(#methods)* @@ -647,3 +648,65 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { } + +/// `maps` a simple type recursively, expanding the type into a series of map calls where the leaf types are operating over +/// unwrapped proxy types (the inner types) +fn map_simple_type(proxy_type : &SimpleType, + input_arg_ident: Cow, + proxy_type_expansion: A, + type_expansion: B) -> proc_macro2::TokenStream +where + A : Fn(&Ident, &Ident) -> proc_macro2::TokenStream, + B : Fn(&Type) -> proc_macro2::TokenStream + { + match proxy_type { + SimpleType::Unit => todo!("Unit type not supported"), + SimpleType::UnitPath (UnitPath{ ident,inner, .. }) => { + let inner = map_simple_type(inner.as_ref(), input_arg_ident.clone(), proxy_type_expansion, type_expansion); + quote_spanned!(ident.span()=> + #input_arg_ident.map(|#input_arg_ident| {#inner}) + ) + }, + SimpleType::Reference { .. } => todo!(), + SimpleType::ProxyType(ProxyType{ proxied_ident, proxy_ident }) => proxy_type_expansion(proxied_ident, proxy_ident), + SimpleType::Type(t) => type_expansion(t), + } +} + +/// `maps` a simple type recursively, expanding the type into a series of map/iter/etc calls where the leaf types are operating over +/// unwrapped proxy types (the inner types). +/// +/// requires arg_name to be a valid identifier refering to the name of the variable containing a value with the SimpleType being mapped. +/// The returned token stream will be an expression. +struct ProxyMapVisitor { + arg_name: Ident, + span: Span, +} + +impl VisitSimpleType for ProxyMapVisitor { + fn visit_unit_path(&self, unit_path: &UnitPath) -> proc_macro2::TokenStream { + let inner = self.visit_simple_type(&unit_path.inner); + let arg_name = &self.arg_name; + quote_spanned!(self.span=> + #arg_name.map(|#arg_name| {#inner}) + ) + } + + fn visit_unit(&self) -> proc_macro2::TokenStream { + quote_spanned!(self.span=> + () + ) + } + + fn visit_proxy_type(&self, proxy_type: &ProxyType) -> proc_macro2::TokenStream { + let proxy_ident = &proxy_type.proxy_ident; + let arg_name = &self.arg_name; + quote_spanned!{self.span=> + #proxy_ident::new(#arg_name) + } + } + + fn visit_type(&self, _type: &Type) -> proc_macro2::TokenStream { + _type.to_token_stream() + } +} \ No newline at end of file From 0f1f82dbb89b72edf4b694d74470a6d0811b38c6 Mon Sep 17 00:00:00 2001 From: makspll Date: Sat, 17 Jun 2023 16:04:07 +0100 Subject: [PATCH 13/94] Add support for outer results in macro --- bevy_mod_scripting_common/src/input.rs | 315 ++++++++++++------ examples/wrappers.rs | 29 +- .../bevy_mod_scripting_lua_derive/src/lib.rs | 223 +++++++++---- 3 files changed, 392 insertions(+), 175 deletions(-) diff --git a/bevy_mod_scripting_common/src/input.rs b/bevy_mod_scripting_common/src/input.rs index 590b32bade..0bdad0d309 100644 --- a/bevy_mod_scripting_common/src/input.rs +++ b/bevy_mod_scripting_common/src/input.rs @@ -1,4 +1,4 @@ -use std::collections::VecDeque; +use std::collections::{HashMap, VecDeque}; use indexmap::{IndexMap, IndexSet}; use proc_macro2::{Ident, Span}; @@ -8,9 +8,9 @@ use syn::{ parse_quote, punctuated::Punctuated, spanned::Spanned, - token::{And, Colon2, Gt, Lt, Mut}, + token::{And, Colon2, Comma, Gt, Lt, Mut}, visit_mut::VisitMut, - AngleBracketedGenericArguments, DataStruct, DeriveInput, Fields, GenericArgument, Meta, + AngleBracketedGenericArguments, DataStruct, DeriveInput, Error, Fields, GenericArgument, Meta, NestedMeta, PatType, Path, PathArguments, PathSegment, Receiver, Token, TraitItemMethod, Type, TypePath, TypeReference, TypeTuple, }; @@ -143,6 +143,17 @@ pub struct UnitPath { pub inner: Box, } +/// For types of the form `Result` i.e. an outer identifier with two nested types inside angle brackets. +#[derive(Debug, Clone)] +pub struct DuoPath { + pub ident: Ident, + pub colon2_token: Option, + pub lt_token: Lt, + pub gt_token: Gt, + pub left: Box, + pub right: Box, +} + /// Represents a type prefixed with an outer reference, e.g. `&T` or `&mut T` #[derive(Debug, Clone)] pub struct Reference { @@ -171,6 +182,9 @@ pub enum SimpleType { Unit, /// A type of the form `Option` UnitPath(UnitPath), + /// A type of the form `Result` a list containing two elements is referred to as a + DuoPath(DuoPath), + /// A type with an outer reference, e.g. `&T` or `&mut T` Reference(Reference), /// A type which doubles as a proxy type, e.g. `T` in `Option` @@ -186,7 +200,8 @@ impl SimpleType { proxy_prefix: &'static str, arg: &syn::FnArg, proxied_type_identifier: &Ident, - ) -> Result { + proxied_to_proxy_ident_map: &HashMap>, + ) -> Result { match arg { syn::FnArg::Receiver(Receiver { reference, @@ -199,6 +214,7 @@ impl SimpleType { proxy_prefix, &Type::Path(ident_to_type_path(proxied_type_identifier.clone())), proxied_type_identifier, + proxied_to_proxy_ident_map, )?); Ok(Self::Reference(Reference { and_token: *and, @@ -210,11 +226,15 @@ impl SimpleType { proxy_prefix, &Type::Path(ident_to_type_path(proxied_type_identifier.clone())), proxied_type_identifier, + proxied_to_proxy_ident_map, ), }, - syn::FnArg::Typed(PatType { ty, .. }) => { - Self::new_from_contextual_type(proxy_prefix, ty.as_ref(), proxied_type_identifier) - } + syn::FnArg::Typed(PatType { ty, .. }) => Self::new_from_contextual_type( + proxy_prefix, + ty.as_ref(), + proxied_type_identifier, + proxied_to_proxy_ident_map, + ), } } @@ -223,8 +243,9 @@ impl SimpleType { pub fn new_from_fully_specified_type( proxy_prefix: &'static str, proxied_type: &Type, - ) -> Result { - Self::new_from_type(proxy_prefix, proxied_type, None) + proxied_to_proxy_ident_map: &HashMap>, + ) -> Result { + Self::new_from_type(proxy_prefix, proxied_type, None, proxied_to_proxy_ident_map) } /// Constructs a new SimpleProxyType from a `syn::Type`, contextual receivers such as `Self` and `self` will be replaced @@ -233,39 +254,66 @@ impl SimpleType { proxy_prefix: &'static str, proxied_type: &Type, proxied_type_identifier: &Ident, - ) -> Result { - Self::new_from_type(proxy_prefix, proxied_type, Some(proxied_type_identifier)) + proxied_to_proxy_ident_map: &HashMap>, + ) -> Result { + Self::new_from_type( + proxy_prefix, + proxied_type, + Some(proxied_type_identifier), + proxied_to_proxy_ident_map, + ) + } + + /// Builds a SimpleType::ProxyType or SimpleType::Type depending on the passed data, + /// - if the proxied type identifier has a Some value in the proxied_to_proxy_ident_map map then the proxy_ident will be set to the value in the map, + /// - if it has a None value it will be set to the proxied type identifier prefixed with the proxy_prefix, + /// - If it's not in the map it's built as a SimpleType::Type + fn new_proxied_type_or_type( + proxy_prefix: &'static str, + proxied_ident: &Ident, + proxied_to_proxy_ident_map: &HashMap>, + ) -> SimpleType { + if let Some((original_ident, replacement_ident)) = + proxied_to_proxy_ident_map.get_key_value(proxied_ident) + { + let proxy_ident = replacement_ident + .as_ref() + .unwrap_or(&format_ident!("{proxy_prefix}{original_ident}")) + .clone(); + + SimpleType::ProxyType(ProxyType { + proxied_ident: original_ident.clone(), + proxy_ident, + }) + } else { + Self::Type(syn::Type::Path(ident_to_type_path(proxied_ident.clone()))) + } } /// Constructs a new SimpleProxyType from a `syn::Type`, if `proxied_type_identifier` is given then contextual /// receivers such as `Self` and `self` will be replaced with the given identifier prefixed with the proxy_prefix, otherwise an error will be returned. + /// types with base identifiers not in the proxied_to_proxy_ident_map list are treated as non-proxy types and will be wrapped in a SimpleProxyType::Type fn new_from_type( proxy_prefix: &'static str, proxied_type: &Type, proxied_type_identifier: Option<&Ident>, - ) -> Result { + proxied_to_proxy_ident_map: &HashMap>, + ) -> Result { match proxied_type { Type::Path(p) if p.path.is_ident("self") || p.path.is_ident("Self") => { - let proxied_ident = proxied_type_identifier.ok_or_else(|| { - ( - proxied_type.span(), + let proxied_ident: &Ident = proxied_type_identifier.ok_or_else(|| { + Error::new_spanned( + proxied_type, "Did not expect contextual receiver in constructing simple proxy type" .to_owned(), ) })?; - - Ok(SimpleType::ProxyType(ProxyType { - proxied_ident: proxied_ident.clone(), - proxy_ident: format_ident!("{}{}", proxy_prefix, proxied_ident), - })) + Ok(Self::new_proxied_type_or_type(proxy_prefix, proxied_ident, proxied_to_proxy_ident_map)) } Type::Path(p) if !p.path.segments.is_empty() => { let last_segment = p.path.segments.last().unwrap(); if last_segment.arguments.is_empty() { - return Ok(SimpleType::ProxyType(ProxyType { - proxied_ident: last_segment.ident.clone(), - proxy_ident: format_ident!("{}{}", proxy_prefix, last_segment.ident), - })); + return Ok(Self::new_proxied_type_or_type(proxy_prefix,&last_segment.ident, proxied_to_proxy_ident_map)); } else if let PathArguments::AngleBracketed(args) = &last_segment.arguments { if args.args.len() == 1 { if let GenericArgument::Type(arg_type) = args.args.first().unwrap() { @@ -273,6 +321,7 @@ impl SimpleType { proxy_prefix, arg_type, proxied_type_identifier, + proxied_to_proxy_ident_map )?); return Ok(SimpleType::UnitPath(UnitPath { ident: last_segment.ident.clone(), @@ -282,9 +331,35 @@ impl SimpleType { inner, })); } + } else if args.args.len() == 2 { + let mut args_iter = args.args.iter(); + if let (GenericArgument::Type(left), GenericArgument::Type(right)) = + (args_iter.next().unwrap(), args_iter.next().unwrap()) + { + let left = Box::new(Self::new_from_type( + proxy_prefix, + left, + proxied_type_identifier, + proxied_to_proxy_ident_map + )?); + let right = Box::new(Self::new_from_type( + proxy_prefix, + right, + proxied_type_identifier, + proxied_to_proxy_ident_map + )?); + return Ok(SimpleType::DuoPath(DuoPath { + ident: last_segment.ident.clone(), + colon2_token: args.colon2_token, + lt_token: args.lt_token, + gt_token: args.gt_token, + left, + right, + })); + } } } - Err((proxied_type.span(), "Unsupported type".to_owned())) + Err(Error::new_spanned(proxied_type, "Unsupported type".to_owned())) } Type::Reference(tr) => Ok(SimpleType::Reference(Reference { and_token: tr.and_token, @@ -293,13 +368,15 @@ impl SimpleType { proxy_prefix, &tr.elem, proxied_type_identifier, + proxied_to_proxy_ident_map )?), })), + Type::Infer(_) => Ok(SimpleType::Type(proxied_type.clone())), Type::Tuple(TypeTuple { elems , ..}) if elems.is_empty() => { Ok(SimpleType::Unit) }, - _ => Err(( - proxied_type.span(), + _ => Err(Error::new_spanned( + proxied_type, format!("Expected simple type with one identifier and possible reference for proxy type, got {}", proxied_type.to_token_stream()), )), } @@ -313,102 +390,126 @@ impl SimpleType { pub fn has_outer_mut_ref(&self) -> bool { matches!(self, SimpleType::Reference (Reference{ mutability, .. }) if mutability.is_some()) } +} - /// Strips outer references and returns the type if any are present - pub fn construct_proxy_type_without_outer_ref(&self) -> Type { - match self { - SimpleType::Reference(Reference { inner, .. }) => inner.construct_proxy_type(), - other => other.construct_proxy_type(), +pub trait VisitSimpleType { + fn visit_simple_type(&mut self, simple_type: &SimpleType) -> T { + match simple_type { + SimpleType::Unit => self.visit_unit(), + SimpleType::UnitPath(unit_path) => self.visit_unit_path(unit_path), + SimpleType::DuoPath(duo_path) => self.visit_duo_path(duo_path), + SimpleType::Reference(reference) => self.visit_reference(reference), + SimpleType::ProxyType(proxy_type) => self.visit_proxy_type(proxy_type), + SimpleType::Type(_type) => self.visit_type(_type), } } + fn visit_unit_path(&mut self, unit_path: &UnitPath) -> T { + self.visit_simple_type(&unit_path.inner) + } - /// Constructs a syn::Type from this SimpleProxyType, representing the proxied type - pub fn construct_proxied_type(&self) -> Type { - self.construct_type_with_proxy_conversion(|proxied_ident, _| { - Type::Path(ident_to_type_path(proxied_ident.clone())) - }) + fn visit_duo_path(&mut self, duo_path: &DuoPath) -> T { + self.visit_simple_type(&duo_path.left); + self.visit_simple_type(&duo_path.right) } - /// Constructs a syn::Type from this SimpleProxyType, representing the proxy type - pub fn construct_proxy_type(&self) -> Type { - self.construct_type_with_proxy_conversion(|_, proxy_ident| { - Type::Path(ident_to_type_path(proxy_ident.clone())) - }) + fn visit_reference(&mut self, reference: &Reference) -> T { + self.visit_simple_type(&reference.inner) } + fn visit_unit(&mut self) -> T; + fn visit_proxy_type(&mut self, proxy_type: &ProxyType) -> T; + fn visit_type(&mut self, _type: &Type) -> T; +} - /// A helper function for constructing a syn::Type from this SimpleProxyType, using the given function to convert - /// the proxied type identifier and proxy type identifier into a syn::Type - fn construct_type_with_proxy_conversion Type>( - &self, - proxy_conversion: F, - ) -> Type { - match self { - SimpleType::UnitPath(UnitPath { - ident, - colon2_token, - lt_token, - gt_token, - inner, - }) => Type::Path(TypePath { - qself: None, - path: PathSegment { - ident: ident.clone(), - arguments: PathArguments::AngleBracketed(AngleBracketedGenericArguments { - colon2_token: *colon2_token, - lt_token: *lt_token, - args: Punctuated::from_iter( - [GenericArgument::Type( - inner.construct_type_with_proxy_conversion(proxy_conversion), - )] - .into_iter(), - ), - gt_token: *gt_token, - }), - } - .into(), - }), - SimpleType::Reference(Reference { - and_token, - mutability, - inner, - }) => Type::Reference(TypeReference { - and_token: *and_token, - lifetime: None, - mutability: *mutability, - elem: Box::new(inner.construct_type_with_proxy_conversion(proxy_conversion)), - }), - SimpleType::Unit => Type::Tuple(TypeTuple { - paren_token: Default::default(), - elems: Default::default(), - }), - SimpleType::Type(_) => todo!(), - SimpleType::ProxyType(ProxyType { - proxied_ident, - proxy_ident, - }) => proxy_conversion(proxied_ident, proxy_ident), +pub struct TypeConstructorVisitor { + /// if true then leaf proxies will be converted to their proxy type, otherwise they will be converted to their proxied type + pub generate_proxy_type: bool, + pub strip_outer_ref: bool, +} + +impl TypeConstructorVisitor { + pub fn new(generate_proxy_type: bool, strip_outer_ref: bool) -> Self { + Self { + generate_proxy_type, + strip_outer_ref, } } } -pub trait VisitSimpleType { - fn visit_simple_type(&self, simple_type: &SimpleType) -> T { - match simple_type { - SimpleType::Unit => self.visit_unit(), - SimpleType::UnitPath(unit_path) => self.visit_unit_path(unit_path), - SimpleType::Reference(reference) => self.visit_reference(reference), - SimpleType::ProxyType(proxy_type) => self.visit_proxy_type(proxy_type), - SimpleType::Type(_type) => self.visit_type(_type), +impl VisitSimpleType for TypeConstructorVisitor { + fn visit_unit(&mut self) -> Type { + Type::Tuple(TypeTuple { + paren_token: Default::default(), + elems: Default::default(), + }) + } + + fn visit_unit_path(&mut self, unit_path: &UnitPath) -> Type { + Type::Path(TypePath { + qself: None, + path: PathSegment { + ident: unit_path.ident.clone(), + arguments: PathArguments::AngleBracketed(AngleBracketedGenericArguments { + colon2_token: unit_path.colon2_token, + lt_token: unit_path.lt_token, + args: Punctuated::from_iter( + [GenericArgument::Type( + self.visit_simple_type(&unit_path.inner), + )] + .into_iter(), + ), + gt_token: unit_path.gt_token, + }), + } + .into(), + }) + } + + fn visit_duo_path(&mut self, duo_path: &DuoPath) -> Type { + let left = self.visit_simple_type(&duo_path.left); + let right = self.visit_simple_type(&duo_path.right); + + Type::Path(TypePath { + qself: None, + path: PathSegment { + ident: duo_path.ident.clone(), + arguments: PathArguments::AngleBracketed(AngleBracketedGenericArguments { + colon2_token: duo_path.colon2_token, + lt_token: duo_path.lt_token, + args: Punctuated::from_iter( + [GenericArgument::Type(left), GenericArgument::Type(right)].into_iter(), + ), + gt_token: duo_path.gt_token, + }), + } + .into(), + }) + } + + fn visit_proxy_type(&mut self, proxy_type: &ProxyType) -> Type { + if self.generate_proxy_type { + Type::Path(ident_to_type_path(proxy_type.proxy_ident.clone())) + } else { + Type::Path(ident_to_type_path(proxy_type.proxied_ident.clone())) } } - fn visit_unit_path(&self, unit_path: &UnitPath) -> T { - self.visit_simple_type(&unit_path.inner) + + fn visit_type(&mut self, _type: &Type) -> Type { + _type.clone() } - fn visit_reference(&self, reference: &Reference) -> T { - self.visit_simple_type(&reference.inner) + + fn visit_reference(&mut self, reference: &Reference) -> Type { + if self.strip_outer_ref { + self.visit_simple_type(&reference.inner) + } else { + self.strip_outer_ref = false; + Type::Reference(TypeReference { + and_token: reference.and_token, + lifetime: None, + mutability: reference.mutability, + elem: Box::new(self.visit_simple_type(&reference.inner)), + }) + } } - fn visit_unit(&self) -> T; - fn visit_proxy_type(&self, proxy_type: &ProxyType) -> T; - fn visit_type(&self, _type: &Type) -> T; } /// Attributes relating to the proxy as a whole diff --git a/examples/wrappers.rs b/examples/wrappers.rs index 6bd0fdcdfa..0746358592 100644 --- a/examples/wrappers.rs +++ b/examples/wrappers.rs @@ -1,10 +1,23 @@ use bevy::{app::AppExit, prelude::*}; - use bevy_mod_scripting::{ api::{impl_lua_newtype, impl_script_newtype, lua::bevy::LuaWorld, ScriptProxy, ScriptRef}, prelude::*, }; +use mlua::Error as LuaError; +use std::error::Error; +use std::fmt::Display; +#[derive(Debug)] +pub struct MyError; + +impl Display for MyError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + todo!() + } +} + +impl Error for MyError {} + // Step 1. Rust representation // construct all our types and functionality // Reflect is neccessary to allow access from scripts @@ -23,12 +36,22 @@ pub struct MyThing { #[proxy(languages("on_feature(lua)"), derive(Clone))] #[functions[ + #[lua(Method, output(proxy))] + fn fn_returning_result(self) -> Result:: { + // let a = self.some_string; + // Ok(Lol{ + // some_string: a + // }) + Err(MyError) + } + #[lua(Method, output(proxy))] fn fn_returning_option(self) -> Option:: { let a = self.some_string; Some(Lol{ some_string: a }) + // None } @@ -61,6 +84,10 @@ pub struct Lol { } impl Lol { + pub fn fn_returning_result(self) -> Result { + Ok(self) + } + pub fn fn_returning_option(self) -> Option { Some(self) } diff --git a/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/languages/bevy_mod_scripting_lua_derive/src/lib.rs index 71b479c7fc..7b5f108058 100644 --- a/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -1,8 +1,8 @@ -use std::borrow::Cow; +use std::{borrow::Cow, iter, collections::HashMap}; use bevy_mod_scripting_common::{ implementor::WrapperImplementor, - input::{DeriveFlag, ProxyMeta, IdentifierRenamingVisitor, SimpleType, UnitPath, ProxyType, VisitSimpleType}, + input::{DeriveFlag, ProxyMeta, IdentifierRenamingVisitor, SimpleType, UnitPath, ProxyType, VisitSimpleType, DuoPath, TypeConstructorVisitor}, newtype::Newtype, utils::{attribute_to_string_lit, ident_to_type_path}, }; @@ -10,12 +10,12 @@ use implementor::LuaImplementor; // use impls::{impl_enum, impl_struct}; use proc_macro::TokenStream; use proc_macro2::{Ident, Span}; -use proc_macro_error::{abort, emit_error, proc_macro_error}; +use proc_macro_error::{abort, emit_error, proc_macro_error, ResultExt}; use quote::{format_ident, quote, quote_spanned, ToTokens}; use syn::{ parse_macro_input, parse_quote, punctuated::Punctuated, spanned::Spanned, token::{Mut, Paren}, Attribute, DeriveInput, Error, FnArg, Lit, Meta, MetaList, NestedMeta, Pat, PatType, Path, - PathArguments, PathSegment, TraitItemMethod, Type, TypePath, PatIdent, visit_mut::VisitMut, TypeTuple, ReturnType}; + PathArguments, PathSegment, TraitItemMethod, Type, TypePath, PatIdent, visit_mut::VisitMut, TypeTuple, ReturnType, MetaNameValue}; pub(crate) mod derive_flags; pub(crate) mod implementor; @@ -63,14 +63,19 @@ struct FunctionArgMeta { impl FunctionArgMeta { /// Creates a new meta structure corresponding to the given function argument. /// Resolves receivers with the given proxy name. - fn new_from_fn_arg(simple_type: &SimpleType, fn_arg: &FnArg) -> Self { + fn new_from_fn_arg(proxied_type_identifier: &Ident,fn_arg: &FnArg) -> Self { let arg_name; let mutable; let variant_data; - + // the proxied type is always proxied with the `Lua` prefix + let mut proxy_ident_map = HashMap::from_iter( + [(proxied_type_identifier.clone(),None)].into_iter() + ); match fn_arg { FnArg::Receiver(receiver) => { - variant_data = ArgVariant::Proxy { proxy_type: simple_type.clone() }; + + let simple_type = SimpleType::new_from_fn_arg(PROXY_PREFIX, fn_arg, proxied_type_identifier, &proxy_ident_map).unwrap_or_abort(); + variant_data = ArgVariant::Proxy { proxy_type: simple_type }; if let Some(_mut) = receiver.mutability { mutable = Some(_mut) @@ -91,7 +96,22 @@ impl FunctionArgMeta { .map(|attr| attr.parse_meta().unwrap_or_else(|err| abort!(attr, err))) .map(|meta| match meta { // #[proxy] - Meta::Path(_) => simple_type.clone(), + Meta::Path(_) => SimpleType::new_from_contextual_type(PROXY_PREFIX, ty, proxied_type_identifier, &proxy_ident_map).unwrap_or_abort(), + // #[proxy(TypeName1=ProxyType1, TypeName2=ProxyType2, ..)] + Meta::List(MetaList { nested, .. }) => { + // collect all the types passed in the meta as identifiers + let idents = nested.iter().map(|nested_meta| { + match nested_meta { + NestedMeta::Meta(Meta::Path(path)) => + (path.get_ident().unwrap_or_else(|| abort!(path,"Expected identifier")).clone(),None), + NestedMeta::Meta(Meta::NameValue(MetaNameValue{path, lit: Lit::Str(lit_str), ..})) => + (path.get_ident().unwrap_or_else(|| abort!(path,"Expected identifier")).clone(), Some(lit_str.parse().unwrap_or_abort())), + _ => abort!(nested_meta.span(), "Expected proxy identifier mapping as in: `proxy(TypeName=ProxyType)` or `proxy(TypeName)` for `LuaTypeName`"), + } + }).collect::)>>(); + proxy_ident_map.extend(idents); + SimpleType::new_from_contextual_type(PROXY_PREFIX, ty, proxied_type_identifier, &proxy_ident_map).unwrap_or_abort() + }, other => abort!(other.span(), "Expected single item attribute list containing proxy name as in: `proxy(\"proxy_name\")`") }); @@ -121,7 +141,7 @@ impl FunctionArgMeta { /// Similar to [`Self::new_from_fn_arg`] but without an option of getting a receiver argument type fn new_from_type( - simple_type: &SimpleType, + proxied_type_identifier: &Ident, arg_name: Ident, arg_type: &Type, attrs: Vec, @@ -141,7 +161,7 @@ impl FunctionArgMeta { }; - Self::new_from_fn_arg(simple_type, &FnArg::Typed(pat_ty)) + Self::new_from_fn_arg(proxied_type_identifier, &FnArg::Typed(pat_ty)) } /// Unpacks non-reference proxy parameters (using the `inner` method) yielding expressions which correspond to the proxied type with conversion errors being @@ -235,11 +255,10 @@ impl FunctionMeta<'_> { .sig .inputs .iter() - .map(|arg| (SimpleType::new_from_fn_arg(PROXY_PREFIX, arg, &proxied_type_identifier).unwrap_or_else(|(s,e)| abort!(s,e)), arg)) - .map(|(simple_type,arg)| FunctionArgMeta::new_from_fn_arg(&simple_type, arg)) + .map(|arg| FunctionArgMeta::new_from_fn_arg(&proxied_type_identifier, arg)) .collect(), output_meta: FunctionArgMeta::new_from_type( - &SimpleType::new_from_contextual_type(PROXY_PREFIX, &output_type, &proxied_type_identifier).unwrap_or_else(|(s,e)| abort!(s,e)), + &proxied_type_identifier, format_ident!("{OUT_ALIAS}"), &output_type, output_attrs, @@ -277,7 +296,7 @@ impl FunctionMeta<'_> { let _mut = &meta.mutable; let self_name = &meta.arg_name; let self_type = match &meta.variant_data { - ArgVariant::Proxy { proxy_type } => proxy_type.construct_proxy_type_without_outer_ref(), + ArgVariant::Proxy { proxy_type } => LuaTypeConstructorVisitor::new(true,true).visit_simple_type(proxy_type), ArgVariant::NonProxy { arg_type } => abort!(arg_type, "Function expects a receiver type as first argument which needs to be a proxy type") , }; @@ -293,7 +312,7 @@ impl FunctionMeta<'_> { // strip outer refs if the type is a proxy, we cannot have any references in type position // we can still have reference semantics since we have a proxy object, however we still pass it by value let type_path = match &fn_arg.variant_data { - ArgVariant::Proxy { proxy_type } => proxy_type.construct_proxy_type_without_outer_ref(), + ArgVariant::Proxy { proxy_type } => LuaTypeConstructorVisitor::new(true,true).visit_simple_type(proxy_type), ArgVariant::NonProxy { arg_type } => arg_type.clone() }; @@ -313,17 +332,24 @@ impl FunctionMeta<'_> { let mut proxied_name = proxied_name.clone(); proxied_name.set_span(self.body.sig.ident.span()); + let function_name = self.name; + // unpack all parameters which need to be unpacked via `.inner` calls, we deal with reference proxies later - let mut unpacked_parameters = self.arg_meta + let unpacked_parameters = self.arg_meta .iter() - .map(FunctionArgMeta::unpack_parameter); + .map(FunctionArgMeta::unpack_parameter) + .collect::>(); - let function_name = self.name; + let param_names = self.arg_meta.iter() + .map(|arg| &arg.arg_name).collect::>(); + + let unpacked_parameter_declarations = quote_spanned!{self.body.span()=> + #(let #param_names = #unpacked_parameters;)* + }; let proxied_method_call = match (self.fn_type.expects_receiver(),&self.body.default){ (_, Some(body)) => { - let param_names = self.arg_meta.iter().map(|arg| &arg.arg_name); let stmts = body.stmts.iter().cloned().map(|mut s| { IdentifierRenamingVisitor{ @@ -334,26 +360,23 @@ impl FunctionMeta<'_> { }); quote_spanned!{body.span()=> - { - #(let #param_names = #unpacked_parameters;)* - (||{ - #(#stmts)* - })() - } + (||{ + #(#stmts)* + })() } }, (true, None) => { // this removes the first argument taken to be the receiver from the iterator for the next step - let first_arg = unpacked_parameters.next().unwrap_or_else(|| abort!(self.name,"Proxied functions of the type: {} expect a receiver argument (i.e. self)", self.fn_type.as_str())); + let (first_arg, other_args) = param_names.split_first().unwrap_or_else(|| abort!(self.name,"Proxied functions of the type: {} expect a receiver argument (i.e. self)", self.fn_type.as_str())); // since we removed the receiver we can pass the rest of the parameters here; quote_spanned! {self.body.span()=> - #first_arg.#function_name(#(#unpacked_parameters),*) + #first_arg.#function_name(#(#other_args),*) } }, (false, None) => { quote_spanned! {self.body.span()=> - #proxied_name::#function_name(#(#unpacked_parameters),*) + #proxied_name::#function_name(#(#param_names),*) } }, }; @@ -367,14 +390,19 @@ impl FunctionMeta<'_> { let constructor_wrapped_expression = ProxyMapVisitor{ arg_name: out_ident.clone(), span: self.body.span() }.visit_simple_type(proxy_type); // the type before we wrap it in a proxy - let proxied_output_type = proxy_type.construct_proxied_type(); + let proxied_output_type = LuaTypeConstructorVisitor::new(false,false).visit_simple_type(proxy_type); // the type after we wrap it in a proxy - let output_type = proxy_type.construct_proxy_type(); + let output_type = LuaTypeConstructorVisitor::new(true,false).visit_simple_type(proxy_type); + // determine if we need to wrap the output in an Ok() statement + let last_statement = match proxy_type { + SimpleType::DuoPath(DuoPath{ ident , ..}) if *ident == "Result" => quote_spanned! {self.body.span()=>__output}, + _ => quote_spanned! {self.body.span()=>Ok(__output)} + }; quote_spanned! {self.body.span()=> let #out_ident : #proxied_output_type = #proxied_method_call; let __output : #output_type = #constructor_wrapped_expression; - Ok(__output) + #last_statement } } ArgVariant::NonProxy{ arg_type } => { @@ -410,7 +438,11 @@ impl FunctionMeta<'_> { acc } }); - reference_unpacked_constructor_wrapped_full_call + + quote!( + #unpacked_parameter_declarations + #reference_unpacked_constructor_wrapped_full_call + ) } @@ -600,7 +632,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { let fn_meta = FunctionMeta::new(proxied_name.clone(), name, body); let args = fn_meta.generate_mlua_args(); - let body = fn_meta.generate_mlua_body(&proxied_name); + let body: proc_macro2::TokenStream = fn_meta.generate_mlua_body(&proxied_name); let closure = quote_spanned! {body.span()=> |#args| { #body @@ -622,7 +654,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { let tealr = quote!(bevy_mod_scripting_lua::tealr); - quote_spanned! {meta.span=> + let a = quote_spanned! {meta.span=> #definition @@ -644,33 +676,63 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { } } - .into() + .into(); + // panic!("{}", a); + a +} + + +/// Wrapper around the `TypeConstructorVisitor` which generates a syn::Type from a `SimpleType`. +/// This is used to handle special cases such as when encountering an outer `Result` where E needs to specifically be converted to an `mlua::Error` on the proxy side +struct LuaTypeConstructorVisitor { + pub general_visitor: TypeConstructorVisitor, +} + +impl LuaTypeConstructorVisitor { + pub fn new(generate_proxy_type: bool, strip_outer_ref: bool) -> Self { + Self { + general_visitor: TypeConstructorVisitor::new(generate_proxy_type,strip_outer_ref), + } + } } +impl VisitSimpleType for LuaTypeConstructorVisitor { + fn visit_unit(&mut self) -> Type { + self.general_visitor.visit_unit() + } + + fn visit_proxy_type(&mut self, proxy_type: &ProxyType) -> Type { + self.general_visitor.visit_proxy_type(proxy_type) + } + + fn visit_type(&mut self, _type: &Type) -> Type { + self.general_visitor.visit_type(_type) + } + + fn visit_unit_path(&mut self, unit_path: &UnitPath) -> Type { + self.general_visitor.visit_unit_path(unit_path) + } + + fn visit_duo_path(&mut self, duo_path: &DuoPath) -> Type { + // this will only trigger for top level types, the deeper nesting is handled by the general visitor + // outer Result needs to be converted to Result when converting to a proxy_type + if duo_path.ident == "Result" && self.general_visitor.generate_proxy_type { + let ident = &duo_path.ident; + let lt_token = duo_path.lt_token; + let gt_token = duo_path.gt_token; + let left = self.visit_simple_type(&duo_path.left); + parse_quote!(#ident #lt_token #left, mlua::Error #gt_token) + } else { + self.general_visitor.visit_duo_path(duo_path) + } + } -/// `maps` a simple type recursively, expanding the type into a series of map calls where the leaf types are operating over -/// unwrapped proxy types (the inner types) -fn map_simple_type(proxy_type : &SimpleType, - input_arg_ident: Cow, - proxy_type_expansion: A, - type_expansion: B) -> proc_macro2::TokenStream -where - A : Fn(&Ident, &Ident) -> proc_macro2::TokenStream, - B : Fn(&Type) -> proc_macro2::TokenStream - { - match proxy_type { - SimpleType::Unit => todo!("Unit type not supported"), - SimpleType::UnitPath (UnitPath{ ident,inner, .. }) => { - let inner = map_simple_type(inner.as_ref(), input_arg_ident.clone(), proxy_type_expansion, type_expansion); - quote_spanned!(ident.span()=> - #input_arg_ident.map(|#input_arg_ident| {#inner}) - ) - }, - SimpleType::Reference { .. } => todo!(), - SimpleType::ProxyType(ProxyType{ proxied_ident, proxy_ident }) => proxy_type_expansion(proxied_ident, proxy_ident), - SimpleType::Type(t) => type_expansion(t), + fn visit_reference(&mut self, reference: &bevy_mod_scripting_common::input::Reference) -> Type { + self.general_visitor.visit_reference(reference) } + + } /// `maps` a simple type recursively, expanding the type into a series of map/iter/etc calls where the leaf types are operating over @@ -684,29 +746,56 @@ struct ProxyMapVisitor { } impl VisitSimpleType for ProxyMapVisitor { - fn visit_unit_path(&self, unit_path: &UnitPath) -> proc_macro2::TokenStream { - let inner = self.visit_simple_type(&unit_path.inner); - let arg_name = &self.arg_name; - quote_spanned!(self.span=> - #arg_name.map(|#arg_name| {#inner}) - ) + + + fn visit_unit_path(&mut self, unit_path: &UnitPath) -> proc_macro2::TokenStream { + let path_string: String = unit_path.ident.to_string(); + + match path_string.as_str() { + "Option" => { + let inner = self.visit_simple_type(&unit_path.inner); + let arg_name = &self.arg_name; + quote_spanned!(self.span=> + #arg_name.map(|#arg_name| #inner) + ) + } + _ => abort!(unit_path.ident, "Unsupported type") + } + } + + fn visit_duo_path(&mut self, duo_path: &DuoPath) -> proc_macro2::TokenStream { + + let path_string: String = duo_path.ident.to_string(); + match path_string.as_str() { + "Result" => { + let left = self.visit_simple_type(&duo_path.left); + let right = self.visit_simple_type(&duo_path.right); + let arg_name = &self.arg_name; + quote_spanned!(self.span=> + #arg_name.map(|#arg_name| #left).map_err(|#arg_name| mlua::Error::external(#right)) + ) + } + _ => abort!(duo_path.ident, "Unsupported type") + } + } - fn visit_unit(&self) -> proc_macro2::TokenStream { + fn visit_unit(&mut self) -> proc_macro2::TokenStream { quote_spanned!(self.span=> () ) } - fn visit_proxy_type(&self, proxy_type: &ProxyType) -> proc_macro2::TokenStream { + fn visit_proxy_type(&mut self, proxy_type: &ProxyType) -> proc_macro2::TokenStream { let proxy_ident = &proxy_type.proxy_ident; - let arg_name = &self.arg_name; + let arg_name = & self.arg_name; quote_spanned!{self.span=> #proxy_ident::new(#arg_name) } } - fn visit_type(&self, _type: &Type) -> proc_macro2::TokenStream { - _type.to_token_stream() + fn visit_type(&mut self, _type: &Type) -> proc_macro2::TokenStream { + self.arg_name.to_token_stream() } + } \ No newline at end of file From dcb6fd9a294c70dd593d5115684651056f4a3d3d Mon Sep 17 00:00:00 2001 From: makspll Date: Tue, 27 Jun 2023 16:20:17 +0100 Subject: [PATCH 14/94] Added UI tests as well as wider type support in macro --- .vscode/settings.json | 3 + bevy_api_gen/src/config.rs | 2 - bevy_mod_scripting_common/Cargo.toml | 1 + bevy_mod_scripting_common/src/input.rs | 186 ++++++++-- bevy_script_api/src/generated.rs | 2 +- examples/wrappers.rs | 24 +- .../bevy_mod_scripting_lua_derive/Cargo.toml | 11 +- .../bevy_mod_scripting_lua_derive/src/lib.rs | 340 ++++++++++-------- .../tests/fail/function-with-receiver.rs | 20 ++ .../tests/fail/function-with-receiver.stderr | 11 + .../tests/fail/invalid-argument-count.rs | 17 + .../tests/fail/invalid-argument-count.stderr | 15 + .../tests/fail/invalid-argument-type.rs | 17 + .../tests/fail/invalid-argument-type.stderr | 13 + .../tests/fail/invalid-function-type.rs | 15 + .../tests/fail/invalid-function-type.stderr | 5 + .../fail/invalid-output-type-custom-body.rs | 15 + .../invalid-output-type-custom-body.stderr | 5 + .../tests/fail/invalid-output-type.rs | 18 + .../tests/fail/invalid-output-type.stderr | 7 + .../tests/fail/method-without-receiver.rs | 20 ++ .../tests/fail/method-without-receiver.stderr | 11 + .../tests/fail/missing-proxy-output-attr.rs | 15 + .../fail/missing-proxy-output-attr.stderr | 5 + .../tests/macro_tests.rs | 11 + .../tests/result.rs | 44 +++ .../tests/success/containers/option.rs | 29 ++ .../tests/success/containers/vec.rs | 24 ++ .../tests/success/simple/function.rs | 32 ++ .../tests/success/simple/metafunction.rs | 23 ++ .../simple/metamethod-owned-receiver.rs | 23 ++ .../tests/success/simple/metamethod.rs | 28 ++ .../success/simple/method-owned-receiver.rs | 29 ++ .../tests/success/simple/method.rs | 29 ++ .../tests/success/simple/mutable-function.rs | 32 ++ .../success/simple/mutable-metafunction.rs | 23 ++ .../mutating-metamethod-owned-receiver.rs | 24 ++ .../success/simple/mutating-metamethod.rs | 24 ++ .../simple/mutating-method-owned-receiver.rs | 29 ++ .../tests/success/simple/mutating-method.rs | 29 ++ 40 files changed, 1010 insertions(+), 201 deletions(-) create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/fail/function-with-receiver.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/fail/function-with-receiver.stderr create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-count.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-count.stderr create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-type.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-type.stderr create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-function-type.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-function-type.stderr create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type-custom-body.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type-custom-body.stderr create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type.stderr create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/fail/method-without-receiver.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/fail/method-without-receiver.stderr create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/fail/missing-proxy-output-attr.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/fail/missing-proxy-output-attr.stderr create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/macro_tests.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/result.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/success/containers/option.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/success/containers/vec.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/success/simple/function.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/success/simple/metafunction.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/success/simple/metamethod-owned-receiver.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/success/simple/metamethod.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/success/simple/method-owned-receiver.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/success/simple/method.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/success/simple/mutable-function.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/success/simple/mutable-metafunction.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/success/simple/mutating-metamethod-owned-receiver.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/success/simple/mutating-metamethod.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/success/simple/mutating-method-owned-receiver.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/success/simple/mutating-method.rs diff --git a/.vscode/settings.json b/.vscode/settings.json index e1b48f9947..a38c6b2d0c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -18,4 +18,7 @@ "editor.formatOnSaveMode": "file", "editor.defaultFormatter": "rust-lang.rust-analyzer" }, + "editor.codeActionsOnSave": { + "source.organizeImports": true + }, } \ No newline at end of file diff --git a/bevy_api_gen/src/config.rs b/bevy_api_gen/src/config.rs index 0d802f57e5..7909dbf874 100644 --- a/bevy_api_gen/src/config.rs +++ b/bevy_api_gen/src/config.rs @@ -1,5 +1,3 @@ -use std::collections::HashSet; - use clap::Parser; use indexmap::{IndexMap, IndexSet}; use rustdoc_types::{Crate, Item, ItemEnum, Visibility}; diff --git a/bevy_mod_scripting_common/Cargo.toml b/bevy_mod_scripting_common/Cargo.toml index 5d3b366f64..15bf3a5dde 100644 --- a/bevy_mod_scripting_common/Cargo.toml +++ b/bevy_mod_scripting_common/Cargo.toml @@ -29,3 +29,4 @@ convert_case = "0.5.0" serde = { version = "1.0", features = ["derive"] } serde_derive = "1.0.137" indexmap = {version= "1.9.1", features= ["serde"]} +strum = { version = "0.24.1", features = ["derive"] } diff --git a/bevy_mod_scripting_common/src/input.rs b/bevy_mod_scripting_common/src/input.rs index 0bdad0d309..fca4ae2a13 100644 --- a/bevy_mod_scripting_common/src/input.rs +++ b/bevy_mod_scripting_common/src/input.rs @@ -1,18 +1,21 @@ -use std::collections::{HashMap, VecDeque}; +use std::{ + collections::{HashMap, VecDeque}, + str::FromStr, +}; use indexmap::{IndexMap, IndexSet}; use proc_macro2::{Ident, Span}; use quote::{format_ident, ToTokens}; +use strum::{Display, EnumString}; use syn::{ parse::{Nothing, Parse}, - parse_quote, punctuated::Punctuated, spanned::Spanned, - token::{And, Colon2, Comma, Gt, Lt, Mut}, + token::{And, Colon2, Gt, Lt, Mut}, visit_mut::VisitMut, AngleBracketedGenericArguments, DataStruct, DeriveInput, Error, Fields, GenericArgument, Meta, - NestedMeta, PatType, Path, PathArguments, PathSegment, Receiver, Token, TraitItemMethod, Type, - TypePath, TypeReference, TypeTuple, + NestedMeta, PatType, PathArguments, PathSegment, Receiver, TraitItemMethod, Type, TypePath, + TypeReference, TypeTuple, }; use crate::utils::{attribute_to_string_lit, ident_to_type_path}; @@ -126,6 +129,24 @@ impl Parse for ZeroOrManyTerminated { } } +/// Enumeration of commonly encountered Rust standard library type identifiers which can be effectively proxied in Lua, +/// These types are `container` types, which wrap other types rather than standalone and literal types. +#[derive(EnumString, Debug, Clone, Copy, Display, PartialEq, Eq)] +pub enum StdTypeIdent { + Option, + Result, + Vec, + Box, + Rc, + Arc, + Cow, + Cell, + RefCell, + Mutex, + RwLock, + Pin, +} + /// Detailed information about the proxy, here we can access fields/variants etc. #[derive(Debug)] pub enum ProxyData { @@ -136,6 +157,7 @@ pub enum ProxyData { /// This type helps us destructure these patterns and unwrap/wrap proxies fully without dealing with the complicated full syn::Type enum #[derive(Debug, Clone)] pub struct UnitPath { + pub std_type_ident: Option, pub ident: Ident, pub colon2_token: Option, pub lt_token: Lt, @@ -146,6 +168,7 @@ pub struct UnitPath { /// For types of the form `Result` i.e. an outer identifier with two nested types inside angle brackets. #[derive(Debug, Clone)] pub struct DuoPath { + pub std_type_ident: Option, pub ident: Ident, pub colon2_token: Option, pub lt_token: Lt, @@ -324,6 +347,7 @@ impl SimpleType { proxied_to_proxy_ident_map )?); return Ok(SimpleType::UnitPath(UnitPath { + std_type_ident: StdTypeIdent::from_str(&last_segment.ident.to_string()).ok(), ident: last_segment.ident.clone(), colon2_token: args.colon2_token, lt_token: args.lt_token, @@ -349,6 +373,7 @@ impl SimpleType { proxied_to_proxy_ident_map )?); return Ok(SimpleType::DuoPath(DuoPath { + std_type_ident: StdTypeIdent::from_str(&last_segment.ident.to_string()).ok(), ident: last_segment.ident.clone(), colon2_token: args.colon2_token, lt_token: args.lt_token, @@ -390,34 +415,60 @@ impl SimpleType { pub fn has_outer_mut_ref(&self) -> bool { matches!(self, SimpleType::Reference (Reference{ mutability, .. }) if mutability.is_some()) } -} -pub trait VisitSimpleType { - fn visit_simple_type(&mut self, simple_type: &SimpleType) -> T { - match simple_type { - SimpleType::Unit => self.visit_unit(), - SimpleType::UnitPath(unit_path) => self.visit_unit_path(unit_path), - SimpleType::DuoPath(duo_path) => self.visit_duo_path(duo_path), - SimpleType::Reference(reference) => self.visit_reference(reference), - SimpleType::ProxyType(proxy_type) => self.visit_proxy_type(proxy_type), - SimpleType::Type(_type) => self.visit_type(_type), + /// Returns true if the type has an inner reference, (e.g. `Type<&T>`) + pub fn has_ref(&self) -> bool { + match self { + SimpleType::Unit => false, + SimpleType::UnitPath(UnitPath { inner, .. }) => inner.has_ref(), + SimpleType::DuoPath(DuoPath { left, right, .. }) => left.has_ref() || right.has_ref(), + SimpleType::Reference(_) => true, + SimpleType::ProxyType(ProxyType { .. }) => false, + SimpleType::Type(_) => false, } } - fn visit_unit_path(&mut self, unit_path: &UnitPath) -> T { - self.visit_simple_type(&unit_path.inner) +} + +pub trait VisitSimpleType +where + T: std::fmt::Debug, +{ + fn visit(&mut self, simple_type: &SimpleType) -> T { + self.visit_simple_type(simple_type, false) + } + + fn visit_simple_type(&mut self, simple_type: &SimpleType, is_child_of_reference: bool) -> T { + let a = match simple_type { + SimpleType::Unit => self.visit_unit(is_child_of_reference), + SimpleType::UnitPath(unit_path) => { + self.visit_unit_path(unit_path, is_child_of_reference) + } + SimpleType::DuoPath(duo_path) => self.visit_duo_path(duo_path, is_child_of_reference), + SimpleType::Reference(reference) => { + self.visit_reference(reference, is_child_of_reference) + } + SimpleType::ProxyType(proxy_type) => { + self.visit_proxy_type(proxy_type, is_child_of_reference) + } + SimpleType::Type(_type) => self.visit_type(_type, is_child_of_reference), + }; + a + } + fn visit_unit_path(&mut self, unit_path: &UnitPath, _is_child_of_reference: bool) -> T { + self.visit_simple_type(&unit_path.inner, false) } - fn visit_duo_path(&mut self, duo_path: &DuoPath) -> T { - self.visit_simple_type(&duo_path.left); - self.visit_simple_type(&duo_path.right) + fn visit_duo_path(&mut self, duo_path: &DuoPath, _is_child_of_reference: bool) -> T { + self.visit_simple_type(&duo_path.left, false); + self.visit_simple_type(&duo_path.right, false) } - fn visit_reference(&mut self, reference: &Reference) -> T { - self.visit_simple_type(&reference.inner) + fn visit_reference(&mut self, reference: &Reference, _is_child_of_reference: bool) -> T { + self.visit_simple_type(&reference.inner, true) } - fn visit_unit(&mut self) -> T; - fn visit_proxy_type(&mut self, proxy_type: &ProxyType) -> T; - fn visit_type(&mut self, _type: &Type) -> T; + fn visit_unit(&mut self, is_child_of_reference: bool) -> T; + fn visit_proxy_type(&mut self, proxy_type: &ProxyType, is_child_of_reference: bool) -> T; + fn visit_type(&mut self, _type: &Type, is_child_of_reference: bool) -> T; } pub struct TypeConstructorVisitor { @@ -436,14 +487,14 @@ impl TypeConstructorVisitor { } impl VisitSimpleType for TypeConstructorVisitor { - fn visit_unit(&mut self) -> Type { + fn visit_unit(&mut self, _: bool) -> Type { Type::Tuple(TypeTuple { paren_token: Default::default(), elems: Default::default(), }) } - fn visit_unit_path(&mut self, unit_path: &UnitPath) -> Type { + fn visit_unit_path(&mut self, unit_path: &UnitPath, _: bool) -> Type { Type::Path(TypePath { qself: None, path: PathSegment { @@ -453,7 +504,7 @@ impl VisitSimpleType for TypeConstructorVisitor { lt_token: unit_path.lt_token, args: Punctuated::from_iter( [GenericArgument::Type( - self.visit_simple_type(&unit_path.inner), + self.visit_simple_type(&unit_path.inner, false), )] .into_iter(), ), @@ -464,9 +515,9 @@ impl VisitSimpleType for TypeConstructorVisitor { }) } - fn visit_duo_path(&mut self, duo_path: &DuoPath) -> Type { - let left = self.visit_simple_type(&duo_path.left); - let right = self.visit_simple_type(&duo_path.right); + fn visit_duo_path(&mut self, duo_path: &DuoPath, _: bool) -> Type { + let left = self.visit_simple_type(&duo_path.left, false); + let right = self.visit_simple_type(&duo_path.right, false); Type::Path(TypePath { qself: None, @@ -485,7 +536,7 @@ impl VisitSimpleType for TypeConstructorVisitor { }) } - fn visit_proxy_type(&mut self, proxy_type: &ProxyType) -> Type { + fn visit_proxy_type(&mut self, proxy_type: &ProxyType, _: bool) -> Type { if self.generate_proxy_type { Type::Path(ident_to_type_path(proxy_type.proxy_ident.clone())) } else { @@ -493,20 +544,20 @@ impl VisitSimpleType for TypeConstructorVisitor { } } - fn visit_type(&mut self, _type: &Type) -> Type { + fn visit_type(&mut self, _type: &Type, _: bool) -> Type { _type.clone() } - fn visit_reference(&mut self, reference: &Reference) -> Type { + fn visit_reference(&mut self, reference: &Reference, _: bool) -> Type { if self.strip_outer_ref { - self.visit_simple_type(&reference.inner) + self.visit_simple_type(&reference.inner, false) } else { self.strip_outer_ref = false; Type::Reference(TypeReference { and_token: reference.and_token, lifetime: None, mutability: reference.mutability, - elem: Box::new(self.visit_simple_type(&reference.inner)), + elem: Box::new(self.visit_simple_type(&reference.inner, true)), }) } } @@ -662,3 +713,66 @@ impl VisitMut for IdentifierRenamingVisitor<'_> { } } } + +#[cfg(test)] +mod test { + use super::VisitSimpleType; + + struct TestVisitor; + impl VisitSimpleType for TestVisitor { + fn visit_unit(&mut self, is_child_of_reference: bool) -> bool { + is_child_of_reference + } + fn visit_proxy_type(&mut self, _: &super::ProxyType, is_child_of_reference: bool) -> bool { + is_child_of_reference + } + fn visit_type(&mut self, _: &syn::Type, is_child_of_reference: bool) -> bool { + is_child_of_reference + } + } + + #[test] + pub fn test_child_of_reference() { + let mut visitor = TestVisitor; + assert!(!visitor.visit(&super::SimpleType::Unit)); + assert!( + !visitor.visit(&super::SimpleType::ProxyType(super::ProxyType { + proxied_ident: syn::Ident::new("T", proc_macro2::Span::call_site()), + proxy_ident: syn::Ident::new("LuaT", proc_macro2::Span::call_site()), + })) + ); + assert!( + !visitor.visit(&super::SimpleType::Type(syn::Type::Path(syn::TypePath { + qself: None, + path: syn::Path::from(syn::Ident::new("T", proc_macro2::Span::call_site())), + }))) + ); + assert!( + visitor.visit(&super::SimpleType::Reference(super::Reference { + and_token: syn::Token![&](proc_macro2::Span::call_site()), + mutability: None, + inner: Box::new(super::SimpleType::Unit), + })) + ); + assert!( + visitor.visit(&super::SimpleType::Reference(super::Reference { + and_token: syn::Token![&](proc_macro2::Span::call_site()), + mutability: None, + inner: Box::new(super::SimpleType::ProxyType(super::ProxyType { + proxied_ident: syn::Ident::new("T", proc_macro2::Span::call_site()), + proxy_ident: syn::Ident::new("LuaT", proc_macro2::Span::call_site()), + })), + })) + ); + assert!( + visitor.visit(&super::SimpleType::Reference(super::Reference { + and_token: syn::Token![&](proc_macro2::Span::call_site()), + mutability: None, + inner: Box::new(super::SimpleType::Type(syn::Type::Path(syn::TypePath { + qself: None, + path: syn::Path::from(syn::Ident::new("T", proc_macro2::Span::call_site())), + }))), + })) + ); + } +} diff --git a/bevy_script_api/src/generated.rs b/bevy_script_api/src/generated.rs index cba47d9105..3137d485d0 100644 --- a/bevy_script_api/src/generated.rs +++ b/bevy_script_api/src/generated.rs @@ -1,4 +1,4 @@ -#![allow(clippy::all, unused_imports)] +#![allow(clippy::all, unused_imports, deprecated)] // This file is generated by `bevy_mod_scripting_derive/main.rs` change the template not this file extern crate self as bevy_script_api; use crate::{ diff --git a/examples/wrappers.rs b/examples/wrappers.rs index 0746358592..e14ddca92d 100644 --- a/examples/wrappers.rs +++ b/examples/wrappers.rs @@ -35,9 +35,17 @@ pub struct MyThing { #[derive(ScriptProxy, Reflect)] #[proxy(languages("on_feature(lua)"), derive(Clone))] #[functions[ + + #[lua(Method, output(proxy))] + fn fn_returning_vec_of_self(self) -> Vec { + vec![_self] + } + + #[lua(Method, output(proxy))] + fn fn_returning_vec(self) -> Vec; #[lua(Method, output(proxy))] - fn fn_returning_result(self) -> Result:: { + fn fn_returning_result(self) -> Result:: { // let a = self.some_string; // Ok(Lol{ // some_string: a @@ -49,7 +57,8 @@ pub struct MyThing { fn fn_returning_option(self) -> Option:: { let a = self.some_string; Some(Lol{ - some_string: a + some_string: a, + me_vec: Default::default(), }) // None } @@ -59,7 +68,8 @@ pub struct MyThing { fn custom_body(self) -> Self { let a = self.some_string; Lol{ - some_string: a + some_string: a, + me_vec: Default::default(), } } @@ -81,9 +91,14 @@ pub struct MyThing { #[derive(Clone)] pub struct Lol { some_string: String, + me_vec: Vec, } impl Lol { + pub fn fn_returning_vec(&self) -> Vec { + self.me_vec.clone() + } + pub fn fn_returning_result(self) -> Result { Ok(self) } @@ -95,6 +110,7 @@ impl Lol { pub fn fn_over_self_and_another(self, another: &Self) -> Self { Self { some_string: "lol".to_owned(), + me_vec: Default::default(), } } @@ -107,12 +123,14 @@ impl Lol { pub fn fn_over_self_ref(&self) -> Self { Self { some_string: "lol".to_owned(), + me_vec: Default::default(), } } pub fn fn_over_self_ref_mut(&mut self) -> Self { Self { some_string: "lol".to_owned(), + me_vec: Default::default(), } } } diff --git a/languages/bevy_mod_scripting_lua_derive/Cargo.toml b/languages/bevy_mod_scripting_lua_derive/Cargo.toml index c130c4614b..d89e3e9e3c 100644 --- a/languages/bevy_mod_scripting_lua_derive/Cargo.toml +++ b/languages/bevy_mod_scripting_lua_derive/Cargo.toml @@ -33,4 +33,13 @@ rustdoc-types = "0.11.0" serde = { version = "1.0", features = ["derive"] } serde_derive = "1.0.137" indexmap = {version= "1.9.1", features= ["serde"]} -proc-macro-error = "1" \ No newline at end of file +proc-macro-error = "1" +strum = { version = "0.24.1", features = ["derive"] } + +[dev-dependencies] +trybuild = "1.0" +bevy = { version = "0.10.1", default-features = false} +bevy_mod_scripting = { path = "../../../bevy_mod_scripting", version = "0.3.0", features=["lua", "lua_script_api", "lua54"] } +bevy_script_api = { path = "../../bevy_script_api", version = "0.3.0" } +bevy_mod_scripting_lua = { path = "../bevy_mod_scripting_lua", version = "0.3.0" } +bevy_mod_scripting_core = { path = "../../bevy_mod_scripting_core", version = "0.3.0" } \ No newline at end of file diff --git a/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/languages/bevy_mod_scripting_lua_derive/src/lib.rs index 7b5f108058..f2ce14580e 100644 --- a/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -1,10 +1,10 @@ -use std::{borrow::Cow, iter, collections::HashMap}; +use std::{collections::{HashMap, HashSet}, str::FromStr}; use bevy_mod_scripting_common::{ implementor::WrapperImplementor, - input::{DeriveFlag, ProxyMeta, IdentifierRenamingVisitor, SimpleType, UnitPath, ProxyType, VisitSimpleType, DuoPath, TypeConstructorVisitor}, + input::{DeriveFlag, ProxyMeta, IdentifierRenamingVisitor, SimpleType, UnitPath, ProxyType, VisitSimpleType, DuoPath, TypeConstructorVisitor, StdTypeIdent}, newtype::Newtype, - utils::{attribute_to_string_lit, ident_to_type_path}, + utils::attribute_to_string_lit, }; use implementor::LuaImplementor; // use impls::{impl_enum, impl_struct}; @@ -12,10 +12,10 @@ use proc_macro::TokenStream; use proc_macro2::{Ident, Span}; use proc_macro_error::{abort, emit_error, proc_macro_error, ResultExt}; use quote::{format_ident, quote, quote_spanned, ToTokens}; +use strum::{EnumString, Display, EnumIter, IntoEnumIterator}; use syn::{ parse_macro_input, parse_quote, punctuated::Punctuated, spanned::Spanned, token::{Mut, Paren}, - Attribute, DeriveInput, Error, FnArg, Lit, Meta, MetaList, NestedMeta, Pat, PatType, Path, - PathArguments, PathSegment, TraitItemMethod, Type, TypePath, PatIdent, visit_mut::VisitMut, TypeTuple, ReturnType, MetaNameValue}; + Attribute, DeriveInput, FnArg, Lit, Meta, MetaList, NestedMeta, Pat, PatType, TraitItemMethod, Type, TypePath, PatIdent, visit_mut::VisitMut, TypeTuple, ReturnType, MetaNameValue}; pub(crate) mod derive_flags; pub(crate) mod implementor; @@ -38,18 +38,6 @@ const SELF_ALIAS: &str = "_self"; const OUT_ALIAS: &str = "__out"; const PROXY_PREFIX: &str = "Lua"; -/// categorises and provides meta data about the broad categories of function arguments/ outputs which are -/// handled by the macro -#[derive(Debug)] -enum ArgVariant { - NonProxy{ - arg_type: Type, - }, - Proxy{ - proxy_type: SimpleType, - }, -} - #[derive(Debug)] struct FunctionArgMeta { mutable: Option, @@ -57,7 +45,7 @@ struct FunctionArgMeta { arg_name: Ident, span: Span, /// variant specific data enumeration - variant_data: ArgVariant, + arg_type: SimpleType, } impl FunctionArgMeta { @@ -66,7 +54,7 @@ impl FunctionArgMeta { fn new_from_fn_arg(proxied_type_identifier: &Ident,fn_arg: &FnArg) -> Self { let arg_name; let mutable; - let variant_data; + let arg_type; // the proxied type is always proxied with the `Lua` prefix let mut proxy_ident_map = HashMap::from_iter( [(proxied_type_identifier.clone(),None)].into_iter() @@ -74,8 +62,7 @@ impl FunctionArgMeta { match fn_arg { FnArg::Receiver(receiver) => { - let simple_type = SimpleType::new_from_fn_arg(PROXY_PREFIX, fn_arg, proxied_type_identifier, &proxy_ident_map).unwrap_or_abort(); - variant_data = ArgVariant::Proxy { proxy_type: simple_type }; + arg_type = SimpleType::new_from_fn_arg(PROXY_PREFIX, fn_arg, proxied_type_identifier, &proxy_ident_map).unwrap_or_abort(); if let Some(_mut) = receiver.mutability { mutable = Some(_mut) @@ -115,11 +102,9 @@ impl FunctionArgMeta { other => abort!(other.span(), "Expected single item attribute list containing proxy name as in: `proxy(\"proxy_name\")`") }); - if let Some(proxy_type) = passed_proxy_type { - variant_data = ArgVariant::Proxy { proxy_type } - } else { - variant_data = ArgVariant::NonProxy { arg_type: *ty.clone()} - } + let empty_idents = Default::default(); + arg_type = passed_proxy_type.unwrap_or_else(|| + SimpleType::new_from_fully_specified_type(PROXY_PREFIX, ty, &empty_idents).unwrap_or_abort()); arg_name = match pat.as_ref() { @@ -135,7 +120,7 @@ impl FunctionArgMeta { mutable, arg_name, span: fn_arg.span(), - variant_data, + arg_type, } } @@ -168,15 +153,8 @@ impl FunctionArgMeta { /// handled by the try `?` operator. pub fn unpack_parameter(&self) -> proc_macro2::TokenStream { let name = &self.arg_name; - // if a proxy parameter is to be passed by value we use inner (which requires Clone to be supported) - if matches!(&self.variant_data, ArgVariant::Proxy{proxy_type} if !proxy_type.has_outer_ref()) { - quote_spanned!(name.span()=> #name.inner()?) - } else { - // if the parameter is not a proxy or a reference - // we do not call anything as .inner() - name.to_token_stream() - } + LuaArgumentUnwrapper::new(name.clone(), name.span()).visit(&self.arg_type) } @@ -226,6 +204,9 @@ impl FunctionMeta<'_> { if let Ok(_fn_type) = FunctionType::from_str(&attr_str) { fn_type = _fn_type; return; + } else { + abort!(p, "Invalid Function Type, expected one of: {}", + FunctionType::iter().map(|ft| ft.to_string()).collect::>().join(", ")) } } else if let NestedMeta::Meta(Meta::List(list)) = attr { if list.path.is_ident("output") { @@ -237,8 +218,7 @@ impl FunctionMeta<'_> { } emit_error!(attr, "unknown or malformed lua proxy function attribute. Allowed attributes include: {}", - FunctionType::iterator() - .map(FunctionType::as_ident_str).collect::>().join(",")); + FunctionType::iter().map(|ft| ft.to_string()).collect::>().join(", ")); }); // if no output type is specified, it's set to the unit type `()` @@ -265,6 +245,7 @@ impl FunctionMeta<'_> { ) , }; + // validate the function against it's meta fn_meta.validate_function_definition(body); @@ -295,10 +276,7 @@ impl FunctionMeta<'_> { if let Some(meta) = args.next() { let _mut = &meta.mutable; let self_name = &meta.arg_name; - let self_type = match &meta.variant_data { - ArgVariant::Proxy { proxy_type } => LuaTypeConstructorVisitor::new(true,true).visit_simple_type(proxy_type), - ArgVariant::NonProxy { arg_type } => abort!(arg_type, "Function expects a receiver type as first argument which needs to be a proxy type") , - }; + let self_type = LuaTypeConstructorVisitor::new(true,true).visit(&meta.arg_type); self_arg = Some(quote_spanned!(meta.span=> , #self_name : & #_mut #self_type)); } @@ -311,11 +289,7 @@ impl FunctionMeta<'_> { // strip outer refs if the type is a proxy, we cannot have any references in type position // we can still have reference semantics since we have a proxy object, however we still pass it by value - let type_path = match &fn_arg.variant_data { - ArgVariant::Proxy { proxy_type } => LuaTypeConstructorVisitor::new(true,true).visit_simple_type(proxy_type), - ArgVariant::NonProxy { arg_type } => arg_type.clone() - }; - + let type_path = LuaTypeConstructorVisitor::new(true,true).visit(&fn_arg.arg_type); ( quote_spanned!(fn_arg.span=>#_mut #name), quote_spanned!(fn_arg.span=>#type_path), @@ -344,7 +318,7 @@ impl FunctionMeta<'_> { .map(|arg| &arg.arg_name).collect::>(); let unpacked_parameter_declarations = quote_spanned!{self.body.span()=> - #(let #param_names = #unpacked_parameters;)* + #(let mut #param_names = #unpacked_parameters;)* }; let proxied_method_call = @@ -367,15 +341,14 @@ impl FunctionMeta<'_> { }, (true, None) => { // this removes the first argument taken to be the receiver from the iterator for the next step - let (first_arg, other_args) = param_names.split_first().unwrap_or_else(|| abort!(self.name,"Proxied functions of the type: {} expect a receiver argument (i.e. self)", self.fn_type.as_str())); - + let (first_arg, other_args) = param_names.split_first().unwrap_or_else(|| abort!(self.name,"Proxied functions of the type: {} expect a receiver argument (i.e. self)", self.fn_type)); // since we removed the receiver we can pass the rest of the parameters here; - quote_spanned! {self.body.span()=> + quote_spanned! {self.body.sig.paren_token.span=> #first_arg.#function_name(#(#other_args),*) } }, (false, None) => { - quote_spanned! {self.body.span()=> + quote_spanned! {self.body.sig.paren_token.span=> #proxied_name::#function_name(#(#param_names),*) } }, @@ -383,19 +356,18 @@ impl FunctionMeta<'_> { // if the output is also a proxied type, we need to wrap the result in a proxy - let constructor_wrapped_full_call= match &self.output_meta.variant_data { - ArgVariant::Proxy{proxy_type} => { + let constructor_wrapped_full_call= { let out_ident = format_ident!("{OUT_ALIAS}"); - let constructor_wrapped_expression = ProxyMapVisitor{ arg_name: out_ident.clone(), span: self.body.span() }.visit_simple_type(proxy_type); + let constructor_wrapped_expression = ProxyConstructorVisitor::new(out_ident.clone(), self.body.span()).visit(&self.output_meta.arg_type); // the type before we wrap it in a proxy - let proxied_output_type = LuaTypeConstructorVisitor::new(false,false).visit_simple_type(proxy_type); + let proxied_output_type = LuaTypeConstructorVisitor::new(false,false).visit(&self.output_meta.arg_type); // the type after we wrap it in a proxy - let output_type = LuaTypeConstructorVisitor::new(true,false).visit_simple_type(proxy_type); + let output_type = LuaTypeConstructorVisitor::new(true,false).visit(&self.output_meta.arg_type); // determine if we need to wrap the output in an Ok() statement - let last_statement = match proxy_type { + let last_statement = match &self.output_meta.arg_type { SimpleType::DuoPath(DuoPath{ ident , ..}) if *ident == "Result" => quote_spanned! {self.body.span()=>__output}, _ => quote_spanned! {self.body.span()=>Ok(__output)} }; @@ -403,14 +375,7 @@ impl FunctionMeta<'_> { let #out_ident : #proxied_output_type = #proxied_method_call; let __output : #output_type = #constructor_wrapped_expression; #last_statement - } - } - ArgVariant::NonProxy{ arg_type } => { - quote_spanned!{self.body.span()=> - let __output : #arg_type = #proxied_method_call; - Ok(__output) - } - } + } }; // for every argument which is a reference, we need a separate sort of call, @@ -418,12 +383,12 @@ impl FunctionMeta<'_> { // structure for the duration of the call let reference_unpacked_constructor_wrapped_full_call = self.arg_meta.iter() .fold(constructor_wrapped_full_call, |acc, arg_meta| { - if let ArgVariant::Proxy{proxy_type} = &arg_meta.variant_data { - if !proxy_type.has_outer_ref(){ + // if let ArgVariant::Proxy{proxy_type} = &arg_meta.variant_data { + if !arg_meta.arg_type.has_outer_ref(){ return acc; } - let method_call = if proxy_type.has_outer_mut_ref() { + let method_call = if arg_meta.arg_type.has_outer_mut_ref() { format_ident!("val_mut") } else { format_ident!("val") @@ -434,10 +399,9 @@ impl FunctionMeta<'_> { quote_spanned!{self.body.span()=>{ #arg_name.#method_call(|#arg_name| {#acc})? }} - } else { - acc } - }); + // } + ); quote!( #unpacked_parameter_declarations @@ -449,6 +413,7 @@ impl FunctionMeta<'_> { fn validate_function_definition(&self, definition: &TraitItemMethod) { + if self.fn_type.expects_receiver() { if let Some(FnArg::Receiver(receiver)) = definition.sig.receiver() { // validate receiver @@ -457,24 +422,32 @@ impl FunctionMeta<'_> { receiver, format!( "Lua proxy functions of type: {}, require `mut self` or `&mut self` argument", - self.fn_type.as_str() + self.fn_type ) ); }; } else { emit_error!( - definition, + definition.sig.paren_token.span, format!( "Lua proxy functions of type: {}, require `self` argument", - self.fn_type.as_str() + self.fn_type ) ) } + } else if definition.sig.receiver().is_some() { + emit_error!( + definition.sig.receiver().unwrap(), + format!( + "Lua proxy functions of type: {}, do not expect a receiver argument", + self.fn_type + ) + ) } } } -#[derive(PartialEq, Eq, Clone, Copy, Debug)] +#[derive(Display, EnumString, EnumIter, PartialEq, Eq, Clone, Copy, Debug)] enum FunctionType { Function, MetaFunction, @@ -487,51 +460,6 @@ enum FunctionType { } impl FunctionType { - pub fn as_str(self) -> &'static str { - match self { - FunctionType::Function => "Function", - FunctionType::MetaFunction => "Meta Function", - FunctionType::Method => "Method", - FunctionType::MetaMethod => "Meta Method", - FunctionType::MutableFunction => "Mutating Function", - FunctionType::MutableMetaFunction => "Mutable Meta Function", - FunctionType::MutatingMethod => "Mutating Method", - FunctionType::MutatingMetaMethod => "Mutating Meta Method", - } - } - - pub fn from_str(str: &str) -> Result { - match str { - "Function" => Ok(FunctionType::Function), - "MetaFunction" => Ok(FunctionType::MetaFunction), - "Method" => Ok(FunctionType::Method), - "MetaMethod" => Ok(FunctionType::MetaMethod), - "MutableFunction" => Ok(FunctionType::MutableFunction), - "MutableMetaFunction" => Ok(FunctionType::MutableMetaFunction), - "MutatingMethod" => Ok(FunctionType::MutatingMethod), - "MutatingMetaMethod" => Ok(FunctionType::MutatingMetaMethod), - _ => Err(()), - } - } - - pub fn as_ident_str(self) -> String { - self.as_str().split_whitespace().collect() - } - - pub fn iterator() -> impl Iterator { - [ - FunctionType::Function, - FunctionType::Method, - FunctionType::MetaMethod, - FunctionType::MetaFunction, - FunctionType::MutableFunction, - FunctionType::MutatingMethod, - FunctionType::MutatingMetaMethod, - FunctionType::MutableMetaFunction, - ] - .into_iter() - } - fn expects_receiver(self) -> bool { self == FunctionType::Method || self == FunctionType::MetaMethod @@ -562,6 +490,7 @@ impl FunctionType { || self == FunctionType::MutatingMetaMethod || self == FunctionType::MutableMetaFunction } + } #[proc_macro_error] @@ -619,6 +548,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { .docstrings .iter() .map(|tkns| quote_spanned!(meta.span=>methods.document_type(#tkns);)); + let tealr = quote!(bevy_mod_scripting_lua::tealr); // generate both tealr documentation and instantiations of functions let methods = meta.functions.iter().map(|(name, body)| { @@ -643,7 +573,46 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { let signature = fn_meta .fn_type .is_meta() - .then(|| fn_meta.name.to_token_stream()) + .then(|| { + let name = fn_meta.name; + let valid_meta_methods : HashSet<&'static str> = HashSet::from_iter([ + "Add", + "Sub", + "Mul", + "Div", + "Mod", + "Pow", + "Unm", + "IDiv", + "BAnd", + "BOr", + "BXor", + "BNot", + "Shl", + "Shr", + "Concat", + "Len", + "Eq", + "Lt", + "Le", + "Index", + "NewIndex", + "Call", + "ToString", + "Pairs", + "IPairs", + "Iter", + "Close", + ].into_iter()); + + // check is valid meta method if not use custom name + if valid_meta_methods.contains(name.to_string().as_str()) { + quote!(#tealr::mlu::mlua::MetaMethod::#name) + } else { + let std_string = name.to_string(); + quote!(#tealr::mlu::mlua::MetaMethod::Custom(#std_string.to_string())) + } + }) .unwrap_or_else(|| fn_meta.name.to_string().to_token_stream()); quote_spanned! {body.span()=> @@ -652,7 +621,6 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { } }); - let tealr = quote!(bevy_mod_scripting_lua::tealr); let a = quote_spanned! {meta.span=> @@ -661,7 +629,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { #tealr_type_implementations #[automatically_derived] - #[allow(unused_parens,unused_braces)] + #[allow(unused_parens,unused_braces,unused_mut)] #[allow(clippy::all)] impl #tealr::mlu::TealData for #proxy_type { @@ -677,11 +645,46 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { } .into(); - // panic!("{}", a); a } +/// Generates an unwrapping expression which can be used to assign the unwrapped proxy to a variable. +struct LuaArgumentUnwrapper { + arg_name: Ident, + span: Span, +} + +impl LuaArgumentUnwrapper { + pub fn new(arg_name: Ident, span: Span) -> Self { + Self { + arg_name, + span, + } + } +} + +impl VisitSimpleType for LuaArgumentUnwrapper { + fn visit_unit(&mut self, _: bool) -> proc_macro2::TokenStream { + quote_spanned!(self.span=> ()) + } + + fn visit_proxy_type(&mut self, _: &ProxyType, is_child_of_reference: bool) -> proc_macro2::TokenStream { + let arg_name: &Ident = &self.arg_name; + + if is_child_of_reference { + quote_spanned!(self.span=> #arg_name) + } else { + quote_spanned!(self.span=> #arg_name.inner()?) + } + } + + fn visit_type(&mut self, _type: &Type, _: bool) -> proc_macro2::TokenStream { + let arg_name: &Ident = &self.arg_name; + quote_spanned!(self.span=> #arg_name) + } +} + /// Wrapper around the `TypeConstructorVisitor` which generates a syn::Type from a `SimpleType`. /// This is used to handle special cases such as when encountering an outer `Result` where E needs to specifically be converted to an `mlua::Error` on the proxy side struct LuaTypeConstructorVisitor { @@ -697,39 +700,40 @@ impl LuaTypeConstructorVisitor { } impl VisitSimpleType for LuaTypeConstructorVisitor { - fn visit_unit(&mut self) -> Type { - self.general_visitor.visit_unit() + fn visit_unit(&mut self, is_child_of_reference: bool) -> Type { + self.general_visitor.visit_unit(is_child_of_reference) } - fn visit_proxy_type(&mut self, proxy_type: &ProxyType) -> Type { - self.general_visitor.visit_proxy_type(proxy_type) + fn visit_proxy_type(&mut self, proxy_type: &ProxyType, is_child_of_reference: bool) -> Type { + self.general_visitor.visit_proxy_type(proxy_type, is_child_of_reference) } - fn visit_type(&mut self, _type: &Type) -> Type { - self.general_visitor.visit_type(_type) + fn visit_type(&mut self, _type: &Type, is_child_of_reference: bool) -> Type { + self.general_visitor.visit_type(_type, is_child_of_reference) } - fn visit_unit_path(&mut self, unit_path: &UnitPath) -> Type { - self.general_visitor.visit_unit_path(unit_path) + fn visit_unit_path(&mut self, unit_path: &UnitPath, is_child_of_reference: bool) -> Type { + self.general_visitor.visit_unit_path(unit_path, is_child_of_reference) } - fn visit_duo_path(&mut self, duo_path: &DuoPath) -> Type { + fn visit_duo_path(&mut self, duo_path: &DuoPath, is_child_of_reference: bool) -> Type { // this will only trigger for top level types, the deeper nesting is handled by the general visitor // outer Result needs to be converted to Result when converting to a proxy_type + let tealr = quote!(bevy_mod_scripting_lua::tealr); - if duo_path.ident == "Result" && self.general_visitor.generate_proxy_type { + if duo_path.std_type_ident.is_some_and(|i| i == StdTypeIdent::Result) && self.general_visitor.generate_proxy_type { let ident = &duo_path.ident; let lt_token = duo_path.lt_token; let gt_token = duo_path.gt_token; - let left = self.visit_simple_type(&duo_path.left); - parse_quote!(#ident #lt_token #left, mlua::Error #gt_token) + let left = self.visit_simple_type(&duo_path.left, false); + parse_quote!(#ident #lt_token #left, #tealr::mlu::mlua::Error #gt_token) } else { - self.general_visitor.visit_duo_path(duo_path) + self.general_visitor.visit_duo_path(duo_path, is_child_of_reference) } } - fn visit_reference(&mut self, reference: &bevy_mod_scripting_common::input::Reference) -> Type { - self.general_visitor.visit_reference(reference) + fn visit_reference(&mut self, reference: &bevy_mod_scripting_common::input::Reference, is_child_of_reference: bool) -> Type { + self.general_visitor.visit_reference(reference, is_child_of_reference) } @@ -740,53 +744,73 @@ impl VisitSimpleType for LuaTypeConstructorVisitor { /// /// requires arg_name to be a valid identifier refering to the name of the variable containing a value with the SimpleType being mapped. /// The returned token stream will be an expression. -struct ProxyMapVisitor { +struct ProxyConstructorVisitor { arg_name: Ident, span: Span, } -impl VisitSimpleType for ProxyMapVisitor { - +impl ProxyConstructorVisitor { + pub fn new(arg_name: Ident, span: Span) -> Self { + Self { + arg_name, + span, + } + } +} - fn visit_unit_path(&mut self, unit_path: &UnitPath) -> proc_macro2::TokenStream { - let path_string: String = unit_path.ident.to_string(); +impl VisitSimpleType for ProxyConstructorVisitor { + - match path_string.as_str() { - "Option" => { - let inner = self.visit_simple_type(&unit_path.inner); + fn visit_unit_path(&mut self, unit_path: &UnitPath, is_child_of_reference: bool) -> proc_macro2::TokenStream { + match unit_path.std_type_ident { + Some(StdTypeIdent::Option) => { + let inner = self.visit_simple_type(&unit_path.inner, false); let arg_name = &self.arg_name; quote_spanned!(self.span=> #arg_name.map(|#arg_name| #inner) ) + }, + Some(StdTypeIdent::Vec) => { + let inner = self.visit_simple_type(&unit_path.inner, false); + let arg_name = &self.arg_name; + let function = is_child_of_reference + .then(|| quote_spanned!(self.span=>as_ref().map(|#arg_name| #inner))) + .unwrap_or_else(|| quote_spanned!(self.span=>map(|#arg_name| #inner))); + + quote_spanned!(self.span=> + #arg_name.into_iter().#function.collect::>() + ) } - _ => abort!(unit_path.ident, "Unsupported type") + Some(unsupported_std_type) => abort!(unit_path.ident, "`{}` is not yet supported", unsupported_std_type), + _ => abort!(unit_path.ident, "Unsupported type"), } } - fn visit_duo_path(&mut self, duo_path: &DuoPath) -> proc_macro2::TokenStream { + fn visit_duo_path(&mut self, duo_path: &DuoPath, _: bool) -> proc_macro2::TokenStream { + let tealr = quote!(bevy_mod_scripting_lua::tealr); - let path_string: String = duo_path.ident.to_string(); - match path_string.as_str() { - "Result" => { - let left = self.visit_simple_type(&duo_path.left); - let right = self.visit_simple_type(&duo_path.right); + match duo_path.std_type_ident { + Some(StdTypeIdent::Result) => { + let left = self.visit_simple_type(&duo_path.left, false); + let right = self.visit_simple_type(&duo_path.right, false); let arg_name = &self.arg_name; quote_spanned!(self.span=> - #arg_name.map(|#arg_name| #left).map_err(|#arg_name| mlua::Error::external(#right)) + #arg_name.map(|#arg_name| #left).map_err(|#arg_name| #tealr::mlu::mlua::Error::external(#right)) ) } + Some(unsupported_std_type) => abort!(duo_path.ident, "`{}` is not yet supported", unsupported_std_type), _ => abort!(duo_path.ident, "Unsupported type") } } - fn visit_unit(&mut self) -> proc_macro2::TokenStream { + fn visit_unit(&mut self, _: bool) -> proc_macro2::TokenStream { quote_spanned!(self.span=> () ) } - fn visit_proxy_type(&mut self, proxy_type: &ProxyType) -> proc_macro2::TokenStream { + fn visit_proxy_type(&mut self, proxy_type: &ProxyType, _: bool) -> proc_macro2::TokenStream { let proxy_ident = &proxy_type.proxy_ident; let arg_name = & self.arg_name; quote_spanned!{self.span=> @@ -794,7 +818,7 @@ impl VisitSimpleType for ProxyMapVisitor { } } - fn visit_type(&mut self, _type: &Type) -> proc_macro2::TokenStream { + fn visit_type(&mut self, _type: &Type, _: bool) -> proc_macro2::TokenStream { self.arg_name.to_token_stream() } diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/function-with-receiver.rs b/languages/bevy_mod_scripting_lua_derive/tests/fail/function-with-receiver.rs new file mode 100644 index 0000000000..a14536abf0 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/function-with-receiver.rs @@ -0,0 +1,20 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(Function)] + fn fn_returning_some_string(self) { + + } + + #[lua(Function)] + fn fn_returning_proxy(&self) { + + } +]] +#[derive(Clone)] +pub struct MyStruct; + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/function-with-receiver.stderr b/languages/bevy_mod_scripting_lua_derive/tests/fail/function-with-receiver.stderr new file mode 100644 index 0000000000..f7f26b6034 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/function-with-receiver.stderr @@ -0,0 +1,11 @@ +error: Lua proxy functions of type: Function, do not expect a receiver argument + --> tests/fail/function-with-receiver.rs:8:33 + | +8 | fn fn_returning_some_string(self) { + | ^^^^ + +error: Lua proxy functions of type: Function, do not expect a receiver argument + --> tests/fail/function-with-receiver.rs:13:27 + | +13 | fn fn_returning_proxy(&self) { + | ^^^^^ diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-count.rs b/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-count.rs new file mode 100644 index 0000000000..7d8eaf2bcb --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-count.rs @@ -0,0 +1,17 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(Method)] + fn my_fn(&self); +]] +#[derive(Clone)] +pub struct MyStruct; + +impl MyStruct { + pub fn my_fn(&self, _: usize) {} +} + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-count.stderr b/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-count.stderr new file mode 100644 index 0000000000..0d8433bc45 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-count.stderr @@ -0,0 +1,15 @@ +error[E0061]: this method takes 1 argument but 0 arguments were supplied + --> tests/fail/invalid-argument-count.rs:8:8 + | +8 | fn my_fn(&self); + | ^^^^^------- an argument of type `usize` is missing + | +note: method defined here + --> tests/fail/invalid-argument-count.rs:14:12 + | +14 | pub fn my_fn(&self, _: usize) {} + | ^^^^^ -------- +help: provide the argument + | +8 | fn my_fn(/* usize */); + | ~~~~~~~~~~~~~ diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-type.rs b/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-type.rs new file mode 100644 index 0000000000..87204b54f5 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-type.rs @@ -0,0 +1,17 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(Method)] + fn my_fn(&self, arg: String); +]] +#[derive(Clone)] +pub struct MyStruct; + +impl MyStruct { + pub fn my_fn(&self, _: usize) {} +} + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-type.stderr b/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-type.stderr new file mode 100644 index 0000000000..912e96cf75 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-type.stderr @@ -0,0 +1,13 @@ +error[E0308]: mismatched types + --> tests/fail/invalid-argument-type.rs:8:21 + | +8 | fn my_fn(&self, arg: String); + | ----- ^^^ expected `usize`, found `String` + | | + | arguments to this method are incorrect + | +note: method defined here + --> tests/fail/invalid-argument-type.rs:14:12 + | +14 | pub fn my_fn(&self, _: usize) {} + | ^^^^^ -------- diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-function-type.rs b/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-function-type.rs new file mode 100644 index 0000000000..45941733c2 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-function-type.rs @@ -0,0 +1,15 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(AMASJDIASDKAW)] + fn fn_taking_nothing() { + + } +]] +#[derive(Clone)] +pub struct MyStruct; + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-function-type.stderr b/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-function-type.stderr new file mode 100644 index 0000000000..296351d86f --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-function-type.stderr @@ -0,0 +1,5 @@ +error: Invalid Function Type, expected one of: Function, MetaFunction, Method, MetaMethod, MutableFunction, MutableMetaFunction, MutatingMethod, MutatingMetaMethod + --> tests/fail/invalid-function-type.rs:7:11 + | +7 | #[lua(AMASJDIASDKAW)] + | ^^^^^^^^^^^^^ diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type-custom-body.rs b/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type-custom-body.rs new file mode 100644 index 0000000000..83858bd12b --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type-custom-body.rs @@ -0,0 +1,15 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(Function)] + fn fn_returning_proxy() -> Self { + 2 + } +]] +#[derive(Clone)] +pub struct MyStruct; + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type-custom-body.stderr b/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type-custom-body.stderr new file mode 100644 index 0000000000..64e9f589a6 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type-custom-body.stderr @@ -0,0 +1,5 @@ +error: Did not expect contextual receiver in constructing simple proxy type + --> tests/fail/invalid-output-type-custom-body.rs:8:32 + | +8 | fn fn_returning_proxy() -> Self { + | ^^^^ diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type.rs b/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type.rs new file mode 100644 index 0000000000..4b88714727 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type.rs @@ -0,0 +1,18 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(Function)] + fn my_fn() -> usize; +]] +#[derive(Clone)] +pub struct MyStruct; + +impl MyStruct { + pub fn my_fn() -> Self { + MyStruct + } +} +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type.stderr b/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type.stderr new file mode 100644 index 0000000000..7d6ef913fc --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type.stderr @@ -0,0 +1,7 @@ +error[E0308]: mismatched types + --> tests/fail/invalid-output-type.rs:8:8 + | +8 | fn my_fn() -> usize; + | ^^^^^^^ ----- expected due to this + | | + | expected `usize`, found `MyStruct` diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/method-without-receiver.rs b/languages/bevy_mod_scripting_lua_derive/tests/fail/method-without-receiver.rs new file mode 100644 index 0000000000..fb2fba3adf --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/method-without-receiver.rs @@ -0,0 +1,20 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(Method)] + fn fn_taking_nothing() { + + } + + #[lua(Method)] + fn fn_taking_usize(arg: usize) { + + } +]] +#[derive(Clone)] +pub struct MyStruct; + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/method-without-receiver.stderr b/languages/bevy_mod_scripting_lua_derive/tests/fail/method-without-receiver.stderr new file mode 100644 index 0000000000..3724381ad1 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/method-without-receiver.stderr @@ -0,0 +1,11 @@ +error: Lua proxy functions of type: Method, require `self` argument + --> tests/fail/method-without-receiver.rs:8:25 + | +8 | fn fn_taking_nothing() { + | ^^ + +error: Lua proxy functions of type: Method, require `self` argument + --> tests/fail/method-without-receiver.rs:13:23 + | +13 | fn fn_taking_usize(arg: usize) { + | ^^^^^^^^^^^^ diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/missing-proxy-output-attr.rs b/languages/bevy_mod_scripting_lua_derive/tests/fail/missing-proxy-output-attr.rs new file mode 100644 index 0000000000..fea37f10b2 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/missing-proxy-output-attr.rs @@ -0,0 +1,15 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(Function)] + fn fn_returning_proxy() -> Self { + MyStruct + } +]] +#[derive(Clone)] +pub struct MyStruct; + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/missing-proxy-output-attr.stderr b/languages/bevy_mod_scripting_lua_derive/tests/fail/missing-proxy-output-attr.stderr new file mode 100644 index 0000000000..b8996fa02e --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/missing-proxy-output-attr.stderr @@ -0,0 +1,5 @@ +error: Did not expect contextual receiver in constructing simple proxy type + --> tests/fail/missing-proxy-output-attr.rs:8:32 + | +8 | fn fn_returning_proxy() -> Self { + | ^^^^ diff --git a/languages/bevy_mod_scripting_lua_derive/tests/macro_tests.rs b/languages/bevy_mod_scripting_lua_derive/tests/macro_tests.rs new file mode 100644 index 0000000000..f009e7ebef --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/macro_tests.rs @@ -0,0 +1,11 @@ +#[test] +fn success() { + let t = trybuild::TestCases::new(); + t.pass("tests/success/**/*.rs"); +} + +#[test] +fn fail() { + let t = trybuild::TestCases::new(); + t.compile_fail("tests/fail/**/*.rs"); +} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/result.rs b/languages/bevy_mod_scripting_lua_derive/tests/result.rs new file mode 100644 index 0000000000..30d57fb69a --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/result.rs @@ -0,0 +1,44 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; +use std::error::Error; +use std::fmt::Display; +use std::fmt::Formatter; + +#[derive(Debug)] +pub struct MyError; + +impl Error for MyError {} + +impl Display for MyError { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + write!(f, "MyError") + } +} + +#[derive(ScriptProxy, Reflect, Clone)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(Function)] + fn fn_returning_usize_result() -> Result { + Ok(2) + } + + #[lua(Function)] + fn fn_returning_usize_result_err() -> Result { + Err(MyError) + } + + + #[lua(Function, output(proxy))] + fn fn_returning_ok_proxy() -> Result { + Ok(MyStruct) + } + + #[lua(Function, output(proxy))] + fn fn_returning_err_proxy() -> Result { + Err(MyError) + } +]] +pub struct MyStruct; + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/success/containers/option.rs b/languages/bevy_mod_scripting_lua_derive/tests/success/containers/option.rs new file mode 100644 index 0000000000..85501577a4 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/success/containers/option.rs @@ -0,0 +1,29 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect, Clone)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(Function)] + fn fn_returning_string_option() -> Option { + Some("hello".to_owned()) + } + + #[lua(Function)] + fn fn_returning_string_option_none() -> Option { + None + } + + #[lua(Function, output(proxy))] + fn fn_returning_some_proxy() -> Option { + Some(MyStruct) + } + + #[lua(Function, output(proxy))] + fn fn_returning_none_proxy() -> Option { + None + } +]] +pub struct MyStruct; + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/success/containers/vec.rs b/languages/bevy_mod_scripting_lua_derive/tests/success/containers/vec.rs new file mode 100644 index 0000000000..4718dad2e7 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/success/containers/vec.rs @@ -0,0 +1,24 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect, Clone)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(Function)] + fn fn_returning_string_vec() -> Vec { + vec!["hello".to_owned()] + } + + #[lua(Function, output(proxy))] + fn fn_returning_proxy_vec() -> Vec { + vec![MyStruct,MyStruct] + } + + #[lua(Function, output(proxy))] + fn fn_returning_proxy_vec_empty() -> Vec { + Vec::default() + } +]] +pub struct MyStruct; + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/success/simple/function.rs b/languages/bevy_mod_scripting_lua_derive/tests/success/simple/function.rs new file mode 100644 index 0000000000..e56a345bc3 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/success/simple/function.rs @@ -0,0 +1,32 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(Function)] + fn fn_returning_some_string() -> String; + + #[lua(Function, output(proxy))] + fn fn_returning_proxy() -> Self; +]] +#[derive(Clone)] +pub struct MyStruct { + some_string: String, + me_vec: Vec, +} + +impl MyStruct { + pub fn fn_returning_some_string() -> String { + "hello".to_owned() + } + + pub fn fn_returning_proxy() -> MyStruct { + MyStruct { + some_string: "hello".to_owned(), + me_vec: vec![1, 2, 3], + } + } +} + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/success/simple/metafunction.rs b/languages/bevy_mod_scripting_lua_derive/tests/success/simple/metafunction.rs new file mode 100644 index 0000000000..7cdf14f671 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/success/simple/metafunction.rs @@ -0,0 +1,23 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(MetaFunction)] + fn ToString(#[proxy] my_struct: &Self) -> String { + my_struct.some_string.clone() + } + + #[lua(MetaFunction, output(proxy))] + fn Index(#[proxy] my_struct: &Self, _i: usize) -> Self { + my_struct.clone() + } +]] +#[derive(Clone)] +pub struct MyStruct { + some_string: String, + me_vec: Vec, +} + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/success/simple/metamethod-owned-receiver.rs b/languages/bevy_mod_scripting_lua_derive/tests/success/simple/metamethod-owned-receiver.rs new file mode 100644 index 0000000000..42b3e8310c --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/success/simple/metamethod-owned-receiver.rs @@ -0,0 +1,23 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(MetaMethod)] + fn ToString(&self) -> String { + self.some_string.clone() + } + + #[lua(MetaMethod, output(proxy))] + fn Index(&self, _idx: usize) -> Self { + self.clone() + } +]] +#[derive(Clone)] +pub struct MyStruct { + some_string: String, + me_vec: Vec, +} + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/success/simple/metamethod.rs b/languages/bevy_mod_scripting_lua_derive/tests/success/simple/metamethod.rs new file mode 100644 index 0000000000..e51f6ac271 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/success/simple/metamethod.rs @@ -0,0 +1,28 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(MetaMethod)] + fn ToString(self) -> String { + self.some_string.clone() + } + + #[lua(MetaMethod, output(proxy))] + fn Index(self, _idx: usize) -> Self { + self.clone() + } + + #[lua(MetaMethod, output(proxy))] + fn Custom(self) { + + } +]] +#[derive(Clone)] +pub struct MyStruct { + some_string: String, + me_vec: Vec, +} + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/success/simple/method-owned-receiver.rs b/languages/bevy_mod_scripting_lua_derive/tests/success/simple/method-owned-receiver.rs new file mode 100644 index 0000000000..97bc76e6e7 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/success/simple/method-owned-receiver.rs @@ -0,0 +1,29 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(Method)] + fn fn_returning_some_string(self) -> String; + + #[lua(Method, output(proxy))] + fn fn_returning_proxy(self) -> Self; +]] +#[derive(Clone)] +pub struct MyStruct { + some_string: String, + me_vec: Vec, +} + +impl MyStruct { + pub fn fn_returning_some_string(self) -> String { + self.some_string + } + + pub fn fn_returning_proxy(self) -> Self { + self.clone() + } +} + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/success/simple/method.rs b/languages/bevy_mod_scripting_lua_derive/tests/success/simple/method.rs new file mode 100644 index 0000000000..354441a6d1 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/success/simple/method.rs @@ -0,0 +1,29 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(Method)] + fn fn_returning_some_string(&self) -> String; + + #[lua(Method,output(proxy))] + fn fn_returning_proxy(&self) -> Self; +]] +#[derive(Clone)] +pub struct MyStruct { + some_string: String, + me_vec: Vec, +} + +impl MyStruct { + pub fn fn_returning_some_string(&self) -> String { + self.some_string.clone() + } + + pub fn fn_returning_proxy(&self) -> Self { + self.clone() + } +} + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/success/simple/mutable-function.rs b/languages/bevy_mod_scripting_lua_derive/tests/success/simple/mutable-function.rs new file mode 100644 index 0000000000..b9e15d9f19 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/success/simple/mutable-function.rs @@ -0,0 +1,32 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(MutableFunction)] + fn fn_returning_some_string() -> String; + + #[lua(MutableFunction, output(proxy))] + fn fn_returning_proxy() -> Self; +]] +#[derive(Clone)] +pub struct MyStruct { + some_string: String, + me_vec: Vec, +} + +impl MyStruct { + pub fn fn_returning_some_string() -> String { + "hello".to_owned() + } + + pub fn fn_returning_proxy() -> Self { + Self { + some_string: "hello".to_owned(), + me_vec: Default::default(), + } + } +} + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/success/simple/mutable-metafunction.rs b/languages/bevy_mod_scripting_lua_derive/tests/success/simple/mutable-metafunction.rs new file mode 100644 index 0000000000..f12ebb5717 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/success/simple/mutable-metafunction.rs @@ -0,0 +1,23 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(MutableMetaFunction)] + fn ToString(#[proxy] my_struct: &Self) -> String { + my_struct.some_string.clone() + } + + #[lua(MutableMetaFunction, output(proxy))] + fn Index(#[proxy] my_struct: &Self, _i: usize) -> Self { + my_struct.clone() + } +]] +#[derive(Clone)] +pub struct MyStruct { + some_string: String, + me_vec: Vec, +} + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/success/simple/mutating-metamethod-owned-receiver.rs b/languages/bevy_mod_scripting_lua_derive/tests/success/simple/mutating-metamethod-owned-receiver.rs new file mode 100644 index 0000000000..c066fbdbc0 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/success/simple/mutating-metamethod-owned-receiver.rs @@ -0,0 +1,24 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(MutatingMetaMethod)] + fn ToString(mut self) -> String { + self.some_string = "lol".to_string(); + self.some_string.clone() + } + + #[lua(MutatingMetaMethod, output(proxy))] + fn Index(mut self, _i: usize) -> Self { + self.clone() + } +]] +#[derive(Clone)] +pub struct MyStruct { + some_string: String, + me_vec: Vec, +} + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/success/simple/mutating-metamethod.rs b/languages/bevy_mod_scripting_lua_derive/tests/success/simple/mutating-metamethod.rs new file mode 100644 index 0000000000..8870bfde06 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/success/simple/mutating-metamethod.rs @@ -0,0 +1,24 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(MutatingMetaMethod)] + fn ToString(&mut self) -> String { + self.some_string = "lol".to_string(); + self.some_string.clone() + } + + #[lua(MutatingMetaMethod, output(proxy))] + fn Index(&mut self, _idx: usize) -> Self { + self.clone() + } +]] +#[derive(Clone)] +pub struct MyStruct { + some_string: String, + me_vec: Vec, +} + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/success/simple/mutating-method-owned-receiver.rs b/languages/bevy_mod_scripting_lua_derive/tests/success/simple/mutating-method-owned-receiver.rs new file mode 100644 index 0000000000..cf0b054392 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/success/simple/mutating-method-owned-receiver.rs @@ -0,0 +1,29 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(MutatingMethod)] + fn fn_returning_some_string(mut self) -> String; + + #[lua(MutatingMethod, output(proxy))] + fn fn_returning_proxy(mut self) -> Self; +]] +#[derive(Clone)] +pub struct MyStruct { + some_string: String, + me_vec: Vec, +} + +impl MyStruct { + pub fn fn_returning_some_string(self) -> String { + self.some_string + } + + pub fn fn_returning_proxy(self) -> Self { + self.clone() + } +} + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/success/simple/mutating-method.rs b/languages/bevy_mod_scripting_lua_derive/tests/success/simple/mutating-method.rs new file mode 100644 index 0000000000..dd52f6791e --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/success/simple/mutating-method.rs @@ -0,0 +1,29 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(MutatingMethod)] + fn fn_returning_some_string(&mut self) -> String; + + #[lua(MutatingMethod, output(proxy))] + fn fn_returning_proxy(&mut self) -> Self; +]] +#[derive(Clone)] +pub struct MyStruct { + some_string: String, + me_vec: Vec, +} + +impl MyStruct { + pub fn fn_returning_some_string(&mut self) -> String { + self.some_string.clone() + } + + pub fn fn_returning_proxy(&mut self) -> Self { + self.clone() + } +} + +pub fn main() {} From b2bb9e5a9b886fa8578900d023cd94975dc28d96 Mon Sep 17 00:00:00 2001 From: makspll Date: Sat, 1 Jul 2023 19:52:47 +0100 Subject: [PATCH 15/94] refactor + add trycompile tests + more parameter support --- bevy_mod_scripting_common/src/input.rs | 19 +- examples/wrappers.rs | 15 + .../bevy_mod_scripting_lua_derive/src/lib.rs | 396 +++++++----------- .../src/visitor.rs | 357 ++++++++++++++++ .../fail/references/non-proxy-reference.rs | 23 + .../references/non-proxy-reference.stderr | 23 + .../references/output-with-proxy-reference.rs | 15 + .../output-with-proxy-reference.stderr | 5 + .../{ => simple}/function-with-receiver.rs | 0 .../function-with-receiver.stderr | 4 +- .../{ => simple}/invalid-argument-count.rs | 0 .../invalid-argument-count.stderr | 4 +- .../{ => simple}/invalid-argument-type.rs | 0 .../{ => simple}/invalid-argument-type.stderr | 4 +- .../{ => simple}/invalid-function-type.rs | 0 .../{ => simple}/invalid-function-type.stderr | 2 +- .../invalid-output-type-custom-body.rs | 0 .../invalid-output-type-custom-body.stderr | 2 +- .../fail/{ => simple}/invalid-output-type.rs | 0 .../{ => simple}/invalid-output-type.stderr | 2 +- .../{ => simple}/method-without-receiver.rs | 0 .../method-without-receiver.stderr | 4 +- .../{ => simple}/missing-proxy-output-attr.rs | 0 .../missing-proxy-output-attr.stderr | 2 +- .../success/containers/option-argument.rs | 20 + .../{option.rs => option-output.rs} | 0 .../tests/success/containers/vec-argument.rs | 19 + .../containers/{vec.rs => vec-output.rs} | 0 .../proxy-non-receiver-reference.rs | 23 + 29 files changed, 673 insertions(+), 266 deletions(-) create mode 100644 languages/bevy_mod_scripting_lua_derive/src/visitor.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/fail/references/non-proxy-reference.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/fail/references/non-proxy-reference.stderr create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/fail/references/output-with-proxy-reference.rs create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/fail/references/output-with-proxy-reference.stderr rename languages/bevy_mod_scripting_lua_derive/tests/fail/{ => simple}/function-with-receiver.rs (100%) rename languages/bevy_mod_scripting_lua_derive/tests/fail/{ => simple}/function-with-receiver.stderr (75%) rename languages/bevy_mod_scripting_lua_derive/tests/fail/{ => simple}/invalid-argument-count.rs (100%) rename languages/bevy_mod_scripting_lua_derive/tests/fail/{ => simple}/invalid-argument-count.stderr (77%) rename languages/bevy_mod_scripting_lua_derive/tests/fail/{ => simple}/invalid-argument-type.rs (100%) rename languages/bevy_mod_scripting_lua_derive/tests/fail/{ => simple}/invalid-argument-type.stderr (74%) rename languages/bevy_mod_scripting_lua_derive/tests/fail/{ => simple}/invalid-function-type.rs (100%) rename languages/bevy_mod_scripting_lua_derive/tests/fail/{ => simple}/invalid-function-type.stderr (81%) rename languages/bevy_mod_scripting_lua_derive/tests/fail/{ => simple}/invalid-output-type-custom-body.rs (100%) rename languages/bevy_mod_scripting_lua_derive/tests/fail/{ => simple}/invalid-output-type-custom-body.stderr (72%) rename languages/bevy_mod_scripting_lua_derive/tests/fail/{ => simple}/invalid-output-type.rs (100%) rename languages/bevy_mod_scripting_lua_derive/tests/fail/{ => simple}/invalid-output-type.stderr (77%) rename languages/bevy_mod_scripting_lua_derive/tests/fail/{ => simple}/method-without-receiver.rs (100%) rename languages/bevy_mod_scripting_lua_derive/tests/fail/{ => simple}/method-without-receiver.stderr (72%) rename languages/bevy_mod_scripting_lua_derive/tests/fail/{ => simple}/missing-proxy-output-attr.rs (100%) rename languages/bevy_mod_scripting_lua_derive/tests/fail/{ => simple}/missing-proxy-output-attr.stderr (73%) create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/success/containers/option-argument.rs rename languages/bevy_mod_scripting_lua_derive/tests/success/containers/{option.rs => option-output.rs} (100%) create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/success/containers/vec-argument.rs rename languages/bevy_mod_scripting_lua_derive/tests/success/containers/{vec.rs => vec-output.rs} (100%) create mode 100644 languages/bevy_mod_scripting_lua_derive/tests/success/references/proxy-non-receiver-reference.rs diff --git a/bevy_mod_scripting_common/src/input.rs b/bevy_mod_scripting_common/src/input.rs index fca4ae2a13..0ffd756673 100644 --- a/bevy_mod_scripting_common/src/input.rs +++ b/bevy_mod_scripting_common/src/input.rs @@ -427,6 +427,20 @@ impl SimpleType { SimpleType::Type(_) => false, } } + + /// Returns true if the type has an inner proxy type + pub fn contains_proxy_type(&self) -> bool { + match self { + SimpleType::Unit => false, + SimpleType::UnitPath(UnitPath { inner, .. }) => inner.contains_proxy_type(), + SimpleType::DuoPath(DuoPath { left, right, .. }) => { + left.contains_proxy_type() || right.contains_proxy_type() + } + SimpleType::Reference(Reference { inner, .. }) => inner.contains_proxy_type(), + SimpleType::ProxyType(_) => true, + SimpleType::Type(_) => false, + } + } } pub trait VisitSimpleType @@ -438,7 +452,7 @@ where } fn visit_simple_type(&mut self, simple_type: &SimpleType, is_child_of_reference: bool) -> T { - let a = match simple_type { + match simple_type { SimpleType::Unit => self.visit_unit(is_child_of_reference), SimpleType::UnitPath(unit_path) => { self.visit_unit_path(unit_path, is_child_of_reference) @@ -451,8 +465,7 @@ where self.visit_proxy_type(proxy_type, is_child_of_reference) } SimpleType::Type(_type) => self.visit_type(_type, is_child_of_reference), - }; - a + } } fn visit_unit_path(&mut self, unit_path: &UnitPath, _is_child_of_reference: bool) -> T { self.visit_simple_type(&unit_path.inner, false) diff --git a/examples/wrappers.rs b/examples/wrappers.rs index e14ddca92d..01e933ac62 100644 --- a/examples/wrappers.rs +++ b/examples/wrappers.rs @@ -36,6 +36,21 @@ pub struct MyThing { #[proxy(languages("on_feature(lua)"), derive(Clone))] #[functions[ + + #[lua(Function)] + fn fn_taking_option(#[proxy] some_str: Option) { + + } + + #[lua(Function)] + fn fn_taking_vec(#[proxy] some_str: Vec) { + } + + #[lua(Method, output(proxy))] + fn fn_returning_vec_of_self_(self, #[proxy] other: &Self) -> Vec { + vec![other.clone()] + } + #[lua(Method, output(proxy))] fn fn_returning_vec_of_self(self) -> Vec { vec![_self] diff --git a/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/languages/bevy_mod_scripting_lua_derive/src/lib.rs index f2ce14580e..f714f0696a 100644 --- a/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -1,26 +1,27 @@ use std::{collections::{HashMap, HashSet}, str::FromStr}; use bevy_mod_scripting_common::{ - implementor::WrapperImplementor, - input::{DeriveFlag, ProxyMeta, IdentifierRenamingVisitor, SimpleType, UnitPath, ProxyType, VisitSimpleType, DuoPath, TypeConstructorVisitor, StdTypeIdent}, - newtype::Newtype, - utils::attribute_to_string_lit, + input::*, + implementor::*, + newtype::*, utils::attribute_to_string_lit, }; use implementor::LuaImplementor; // use impls::{impl_enum, impl_struct}; use proc_macro::TokenStream; -use proc_macro2::{Ident, Span}; -use proc_macro_error::{abort, emit_error, proc_macro_error, ResultExt}; -use quote::{format_ident, quote, quote_spanned, ToTokens}; -use strum::{EnumString, Display, EnumIter, IntoEnumIterator}; -use syn::{ - parse_macro_input, parse_quote, punctuated::Punctuated, spanned::Spanned, token::{Mut, Paren}, - Attribute, DeriveInput, FnArg, Lit, Meta, MetaList, NestedMeta, Pat, PatType, TraitItemMethod, Type, TypePath, PatIdent, visit_mut::VisitMut, TypeTuple, ReturnType, MetaNameValue}; +use proc_macro2::*; +use proc_macro_error::*; +use quote::*; +use strum::*; +use syn::{*, spanned::*, token::{Mut, Paren}, punctuated::Punctuated, visit_mut::VisitMut}; +use visitor::{LuaSimpleTypeArgumentUnwrapper, LuaTypeConstructorVisitor}; + +use crate::visitor::LuaSimpleTypeWrapper; pub(crate) mod derive_flags; pub(crate) mod implementor; pub(crate) mod impls; pub(crate) mod lua_method; +pub(crate) mod visitor; #[proc_macro] pub fn impl_lua_newtype(tokens: TokenStream) -> TokenStream { @@ -35,7 +36,8 @@ pub fn impl_lua_newtype(tokens: TokenStream) -> TokenStream { } const SELF_ALIAS: &str = "_self"; -const OUT_ALIAS: &str = "__out"; +const PROXIED_OUT_ALIAS: &str = "__proxied_out"; +const PROXY_OUT_ALIAS: &str = "__proxy_out"; const PROXY_PREFIX: &str = "Lua"; #[derive(Debug)] @@ -51,10 +53,15 @@ struct FunctionArgMeta { impl FunctionArgMeta { /// Creates a new meta structure corresponding to the given function argument. /// Resolves receivers with the given proxy name. - fn new_from_fn_arg(proxied_type_identifier: &Ident,fn_arg: &FnArg) -> Self { + /// Uses given span if available, otherwise uses the span of the function argument + fn new_from_fn_arg(proxied_type_identifier: &Ident, fn_arg: &FnArg, span: Option) -> Self { let arg_name; let mutable; let arg_type; + let span = span.unwrap_or(fn_arg.span()); + let proxied_type_identifier = &mut proxied_type_identifier.clone(); + proxied_type_identifier.set_span(span); + // the proxied type is always proxied with the `Lua` prefix let mut proxy_ident_map = HashMap::from_iter( [(proxied_type_identifier.clone(),None)].into_iter() @@ -70,7 +77,7 @@ impl FunctionArgMeta { mutable = None } - arg_name = format_ident!("{}", SELF_ALIAS); + arg_name = format_ident!("{}", SELF_ALIAS, span=span); } FnArg::Typed(PatType { attrs, pat, ty, .. }) => { let proxy_attr = attrs @@ -119,7 +126,7 @@ impl FunctionArgMeta { FunctionArgMeta { mutable, arg_name, - span: fn_arg.span(), + span, arg_type, } } @@ -145,8 +152,8 @@ impl FunctionArgMeta { ty, }; - - Self::new_from_fn_arg(proxied_type_identifier, &FnArg::Typed(pat_ty)) + let fn_arg = FnArg::Typed(pat_ty); + Self::new_from_fn_arg(proxied_type_identifier, &fn_arg, Some(arg_type.span())) } /// Unpacks non-reference proxy parameters (using the `inner` method) yielding expressions which correspond to the proxied type with conversion errors being @@ -154,7 +161,7 @@ impl FunctionArgMeta { pub fn unpack_parameter(&self) -> proc_macro2::TokenStream { let name = &self.arg_name; // if a proxy parameter is to be passed by value we use inner (which requires Clone to be supported) - LuaArgumentUnwrapper::new(name.clone(), name.span()).visit(&self.arg_type) + LuaSimpleTypeArgumentUnwrapper::new(name.clone(), name.span()).visit(&self.arg_type) } @@ -235,11 +242,11 @@ impl FunctionMeta<'_> { .sig .inputs .iter() - .map(|arg| FunctionArgMeta::new_from_fn_arg(&proxied_type_identifier, arg)) + .map(|arg| FunctionArgMeta::new_from_fn_arg(&proxied_type_identifier, arg, None)) .collect(), output_meta: FunctionArgMeta::new_from_type( &proxied_type_identifier, - format_ident!("{OUT_ALIAS}"), + format_ident!("{PROXIED_OUT_ALIAS}", span=body.sig.output.span()), &output_type, output_attrs, ) @@ -286,10 +293,9 @@ impl FunctionMeta<'_> { .map(|fn_arg| { let _mut = &fn_arg.mutable; let name = &fn_arg.arg_name; - - // strip outer refs if the type is a proxy, we cannot have any references in type position + // strip outer refs if the type contains a proxy, we cannot have any references in type position // we can still have reference semantics since we have a proxy object, however we still pass it by value - let type_path = LuaTypeConstructorVisitor::new(true,true).visit(&fn_arg.arg_type); + let type_path = LuaTypeConstructorVisitor::new(true,fn_arg.arg_type.contains_proxy_type()).visit(&fn_arg.arg_type); ( quote_spanned!(fn_arg.span=>#_mut #name), quote_spanned!(fn_arg.span=>#type_path), @@ -300,29 +306,54 @@ impl FunctionMeta<'_> { quote_spanned!(self.body.sig.inputs.span()=>_ #self_arg , (#(#args),*) : (#(#arg_types),*)) } - fn generate_mlua_body(&self, proxied_name: &Ident) -> proc_macro2::TokenStream { - - // override this span, as otherwise spans propagate weird - let mut proxied_name = proxied_name.clone(); - proxied_name.set_span(self.body.sig.ident.span()); - - let function_name = self.name; + /// Takes all the argument identifiers passed into the function, generates assignments which shadow the original + /// identifiers but modifies the parameter types if required by unpacking proxies. This is done via `.inner` calls on proxy wrappers + /// + /// For example for the type `MyType` + /// `fn my_fn(self, #[proxy] other_ref: &Self, #[proxy] other: Self)` + /// + /// will generate the following statements: + /// ```rust,ignore + /// let _self : MyType = self.inner(); + /// let other_ref : LuaMyType = other; // note this one is kept as a wrapper, and dealt in another process + /// let other : MyType = other_ref.inner(); + /// ``` + fn generate_mlua_body_unwrapped_parameter_assignments(&self) -> proc_macro2::TokenStream { + let param_names = self.arg_meta + .iter() + .map(|arg| &arg.arg_name); - // unpack all parameters which need to be unpacked via `.inner` calls, we deal with reference proxies later let unpacked_parameters = self.arg_meta .iter() .map(FunctionArgMeta::unpack_parameter) .collect::>(); - let param_names = self.arg_meta.iter() - .map(|arg| &arg.arg_name).collect::>(); - - let unpacked_parameter_declarations = quote_spanned!{self.body.span()=> + quote_spanned!{self.body.span()=> #(let mut #param_names = #unpacked_parameters;)* - }; + } + } + + + /// Generates the statement which calls the proxied function with the same argument names as in the function declaration + /// and stores the output in a variable with the given identifier. Static methods, are called against the given `proxied_name` + /// + /// For example for the type `MyType` with proxied ident `__proxied_out` + /// `fn my_fn(self, #[proxy] other_ref: &Self, #[proxy] other: Self) -> Self` + /// + /// will generate the following statement: + /// ```rust,ignore + /// let __proxied_out : MyType = self.my_fn(other_ref, other); + /// ``` + fn generate_mlua_body_proxied_output_stmt(&self, proxied_output_ident: &Ident, proxied_name: &Ident) -> proc_macro2::TokenStream { + // generate function call on proxied type (operating over unwrapped parameters) + // output will be stored in out_ident with the proxied_output_type + // the type before we wrap it in a proxy + let proxied_output_type = LuaTypeConstructorVisitor::new(false,false).visit(&self.output_meta.arg_type); - let proxied_method_call = - match (self.fn_type.expects_receiver(),&self.body.default){ + let function_name = self.name; + let param_names = self.arg_meta.iter() + .map(|arg| &arg.arg_name).collect::>(); + match (self.fn_type.expects_receiver(), &self.body.default){ (_, Some(body)) => { let stmts = body.stmts.iter().cloned().map(|mut s| { @@ -334,9 +365,10 @@ impl FunctionMeta<'_> { }); quote_spanned!{body.span()=> - (||{ - #(#stmts)* - })() + let #proxied_output_ident : #proxied_output_type = + (||{ + #(#stmts)* + })(); } }, (true, None) => { @@ -344,54 +376,85 @@ impl FunctionMeta<'_> { let (first_arg, other_args) = param_names.split_first().unwrap_or_else(|| abort!(self.name,"Proxied functions of the type: {} expect a receiver argument (i.e. self)", self.fn_type)); // since we removed the receiver we can pass the rest of the parameters here; quote_spanned! {self.body.sig.paren_token.span=> - #first_arg.#function_name(#(#other_args),*) + let #proxied_output_ident : #proxied_output_type = + #first_arg.#function_name(#(#other_args),*); } }, (false, None) => { + // override this span, as otherwise spans propagate weird + let mut proxied_name = proxied_name.clone(); + proxied_name.set_span(self.body.sig.ident.span()); + quote_spanned! {self.body.sig.paren_token.span=> - #proxied_name::#function_name(#(#param_names),*) + let #proxied_output_ident : #proxied_output_type = + #proxied_name::#function_name(#(#param_names),*); } }, - }; + } + } + + /// Generates a wrapping statement, which if the type present in the `proxied_output_ident` variable needs to be wrapped into a proxy constructor, will do so and assign + /// the output to the given `proxy_output_ident`. + /// + /// For example for the type: `MyType` with `__proxy_out output` identifier + /// the function: `fn my_fn(self, #[proxy] other_ref: &Self, #[proxy] other: Self) -> Self` + /// will generate the following statement: + /// ```rust,ignore + /// let __proxy_out : LuaMyType = LuaMyType::new(__proxied_out); + /// ``` + fn generate_mlua_body_proxy_output_stmt(&self, proxied_output_ident: &Ident, proxy_output_ident: &Ident) -> proc_macro2::TokenStream { + // generate `new` calls as required to build proxy stored in out_ident + let constructor_wrapped_expression = + LuaSimpleTypeWrapper::new(proxied_output_ident.clone(), proxied_output_ident.span()) + .visit(&self.output_meta.arg_type); + + // the type of the wrapped type (if wrapped) + let proxy_output_type = LuaTypeConstructorVisitor::new(true,false).visit(&self.output_meta.arg_type); + + // the statement assigning the proxy output to proxy_output_ident + quote_spanned! {self.body.span()=> + let #proxy_output_ident : #proxy_output_type = #constructor_wrapped_expression; + } + } + fn generate_mlua_body(&self, proxied_name: &Ident) -> proc_macro2::TokenStream { - // if the output is also a proxied type, we need to wrap the result in a proxy - let constructor_wrapped_full_call= { - let out_ident = format_ident!("{OUT_ALIAS}"); - let constructor_wrapped_expression = ProxyConstructorVisitor::new(out_ident.clone(), self.body.span()).visit(&self.output_meta.arg_type); + let unpacked_parameter_declarations = self.generate_mlua_body_unwrapped_parameter_assignments(); - // the type before we wrap it in a proxy - let proxied_output_type = LuaTypeConstructorVisitor::new(false,false).visit(&self.output_meta.arg_type); - // the type after we wrap it in a proxy - let output_type = LuaTypeConstructorVisitor::new(true,false).visit(&self.output_meta.arg_type); - - // determine if we need to wrap the output in an Ok() statement - let last_statement = match &self.output_meta.arg_type { - SimpleType::DuoPath(DuoPath{ ident , ..}) if *ident == "Result" => quote_spanned! {self.body.span()=>__output}, - _ => quote_spanned! {self.body.span()=>Ok(__output)} - }; - quote_spanned! {self.body.span()=> - let #out_ident : #proxied_output_type = #proxied_method_call; - let __output : #output_type = #constructor_wrapped_expression; - #last_statement - } + let proxied_output_ident = format_ident!("{PROXIED_OUT_ALIAS}", span=self.output_meta.span); + let proxy_output_ident: Ident = format_ident!("{PROXY_OUT_ALIAS}", span=self.output_meta.span); + + let proxied_output_stmt = self.generate_mlua_body_proxied_output_stmt(&proxied_output_ident, proxied_name); + let proxy_output_stmt = self.generate_mlua_body_proxy_output_stmt(&proxied_output_ident, &proxy_output_ident); + + // determine if we need to wrap the output in an Ok() statement + let last_stm = match &self.output_meta.arg_type { + SimpleType::DuoPath(DuoPath{ ident , ..}) if *ident == "Result" => quote_spanned! {self.body.span()=>#proxy_output_ident}, + _ => quote_spanned! {self.body.span()=>Ok(#proxy_output_ident)} }; + + let conversion_body_stms = quote!( + #proxied_output_stmt + #proxy_output_stmt + #last_stm + ); // for every argument which is a reference, we need a separate sort of call, // we cannot use `v.inner()` since this operates over values, we must use `val_mut` or `val` to get a reference to the wrapped // structure for the duration of the call - let reference_unpacked_constructor_wrapped_full_call = self.arg_meta.iter() - .fold(constructor_wrapped_full_call, |acc, arg_meta| { - // if let ArgVariant::Proxy{proxy_type} = &arg_meta.variant_data { - if !arg_meta.arg_type.has_outer_ref(){ + let conversion_body_surrounded_with_dereferening_stms = self.arg_meta.iter() + .fold(conversion_body_stms, |acc, arg_meta| { + // only proxy types which are directly inside a reference are supported as references + if !matches!(arg_meta.arg_type, SimpleType::Reference(Reference{ ref inner, .. }) + if matches!(inner.as_ref(), SimpleType::ProxyType(_))){ return acc; } let method_call = if arg_meta.arg_type.has_outer_mut_ref() { - format_ident!("val_mut") + format_ident!("val_mut", span=arg_meta.span) } else { - format_ident!("val") + format_ident!("val", span=arg_meta.span) }; let arg_name = &arg_meta.arg_name; @@ -400,12 +463,12 @@ impl FunctionMeta<'_> { #arg_name.#method_call(|#arg_name| {#acc})? }} } - // } ); + quote!( #unpacked_parameter_declarations - #reference_unpacked_constructor_wrapped_full_call + #conversion_body_surrounded_with_dereferening_stms ) } @@ -413,6 +476,14 @@ impl FunctionMeta<'_> { fn validate_function_definition(&self, definition: &TraitItemMethod) { + if self.output_meta.arg_type.has_ref() && self.output_meta.arg_type.contains_proxy_type() { + emit_error!( + self.output_meta.span, + format!( + "Lua proxy functions do not support non 'static types as return values yet" + ) + ) + } if self.fn_type.expects_receiver() { if let Some(FnArg::Receiver(receiver)) = definition.sig.receiver() { @@ -569,7 +640,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { } }; - let tealr_function = format_ident!("{}", fn_meta.fn_type.get_tealr_function()); + let tealr_function = format_ident!("{}", fn_meta.fn_type.get_tealr_function(), span=body.span()); let signature = fn_meta .fn_type .is_meta() @@ -622,7 +693,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { }); - let a = quote_spanned! {meta.span=> + quote_spanned! {meta.span=> #definition @@ -644,182 +715,5 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { } } - .into(); - a -} - - -/// Generates an unwrapping expression which can be used to assign the unwrapped proxy to a variable. -struct LuaArgumentUnwrapper { - arg_name: Ident, - span: Span, -} - -impl LuaArgumentUnwrapper { - pub fn new(arg_name: Ident, span: Span) -> Self { - Self { - arg_name, - span, - } - } -} - -impl VisitSimpleType for LuaArgumentUnwrapper { - fn visit_unit(&mut self, _: bool) -> proc_macro2::TokenStream { - quote_spanned!(self.span=> ()) - } - - fn visit_proxy_type(&mut self, _: &ProxyType, is_child_of_reference: bool) -> proc_macro2::TokenStream { - let arg_name: &Ident = &self.arg_name; - - if is_child_of_reference { - quote_spanned!(self.span=> #arg_name) - } else { - quote_spanned!(self.span=> #arg_name.inner()?) - } - } - - fn visit_type(&mut self, _type: &Type, _: bool) -> proc_macro2::TokenStream { - let arg_name: &Ident = &self.arg_name; - quote_spanned!(self.span=> #arg_name) - } -} - -/// Wrapper around the `TypeConstructorVisitor` which generates a syn::Type from a `SimpleType`. -/// This is used to handle special cases such as when encountering an outer `Result` where E needs to specifically be converted to an `mlua::Error` on the proxy side -struct LuaTypeConstructorVisitor { - pub general_visitor: TypeConstructorVisitor, -} - -impl LuaTypeConstructorVisitor { - pub fn new(generate_proxy_type: bool, strip_outer_ref: bool) -> Self { - Self { - general_visitor: TypeConstructorVisitor::new(generate_proxy_type,strip_outer_ref), - } - } -} - -impl VisitSimpleType for LuaTypeConstructorVisitor { - fn visit_unit(&mut self, is_child_of_reference: bool) -> Type { - self.general_visitor.visit_unit(is_child_of_reference) - } - - fn visit_proxy_type(&mut self, proxy_type: &ProxyType, is_child_of_reference: bool) -> Type { - self.general_visitor.visit_proxy_type(proxy_type, is_child_of_reference) - } - - fn visit_type(&mut self, _type: &Type, is_child_of_reference: bool) -> Type { - self.general_visitor.visit_type(_type, is_child_of_reference) - } - - fn visit_unit_path(&mut self, unit_path: &UnitPath, is_child_of_reference: bool) -> Type { - self.general_visitor.visit_unit_path(unit_path, is_child_of_reference) - } - - fn visit_duo_path(&mut self, duo_path: &DuoPath, is_child_of_reference: bool) -> Type { - // this will only trigger for top level types, the deeper nesting is handled by the general visitor - // outer Result needs to be converted to Result when converting to a proxy_type - let tealr = quote!(bevy_mod_scripting_lua::tealr); - - if duo_path.std_type_ident.is_some_and(|i| i == StdTypeIdent::Result) && self.general_visitor.generate_proxy_type { - let ident = &duo_path.ident; - let lt_token = duo_path.lt_token; - let gt_token = duo_path.gt_token; - let left = self.visit_simple_type(&duo_path.left, false); - parse_quote!(#ident #lt_token #left, #tealr::mlu::mlua::Error #gt_token) - } else { - self.general_visitor.visit_duo_path(duo_path, is_child_of_reference) - } - } - - fn visit_reference(&mut self, reference: &bevy_mod_scripting_common::input::Reference, is_child_of_reference: bool) -> Type { - self.general_visitor.visit_reference(reference, is_child_of_reference) - } - - -} - -/// `maps` a simple type recursively, expanding the type into a series of map/iter/etc calls where the leaf types are operating over -/// unwrapped proxy types (the inner types). -/// -/// requires arg_name to be a valid identifier refering to the name of the variable containing a value with the SimpleType being mapped. -/// The returned token stream will be an expression. -struct ProxyConstructorVisitor { - arg_name: Ident, - span: Span, -} - -impl ProxyConstructorVisitor { - pub fn new(arg_name: Ident, span: Span) -> Self { - Self { - arg_name, - span, - } - } -} - -impl VisitSimpleType for ProxyConstructorVisitor { - - - fn visit_unit_path(&mut self, unit_path: &UnitPath, is_child_of_reference: bool) -> proc_macro2::TokenStream { - match unit_path.std_type_ident { - Some(StdTypeIdent::Option) => { - let inner = self.visit_simple_type(&unit_path.inner, false); - let arg_name = &self.arg_name; - quote_spanned!(self.span=> - #arg_name.map(|#arg_name| #inner) - ) - }, - Some(StdTypeIdent::Vec) => { - let inner = self.visit_simple_type(&unit_path.inner, false); - let arg_name = &self.arg_name; - let function = is_child_of_reference - .then(|| quote_spanned!(self.span=>as_ref().map(|#arg_name| #inner))) - .unwrap_or_else(|| quote_spanned!(self.span=>map(|#arg_name| #inner))); - - quote_spanned!(self.span=> - #arg_name.into_iter().#function.collect::>() - ) - } - Some(unsupported_std_type) => abort!(unit_path.ident, "`{}` is not yet supported", unsupported_std_type), - _ => abort!(unit_path.ident, "Unsupported type"), - } - } - - fn visit_duo_path(&mut self, duo_path: &DuoPath, _: bool) -> proc_macro2::TokenStream { - let tealr = quote!(bevy_mod_scripting_lua::tealr); - - match duo_path.std_type_ident { - Some(StdTypeIdent::Result) => { - let left = self.visit_simple_type(&duo_path.left, false); - let right = self.visit_simple_type(&duo_path.right, false); - let arg_name = &self.arg_name; - quote_spanned!(self.span=> - #arg_name.map(|#arg_name| #left).map_err(|#arg_name| #tealr::mlu::mlua::Error::external(#right)) - ) - } - Some(unsupported_std_type) => abort!(duo_path.ident, "`{}` is not yet supported", unsupported_std_type), - _ => abort!(duo_path.ident, "Unsupported type") - } - - } - - fn visit_unit(&mut self, _: bool) -> proc_macro2::TokenStream { - quote_spanned!(self.span=> - () - ) - } - - fn visit_proxy_type(&mut self, proxy_type: &ProxyType, _: bool) -> proc_macro2::TokenStream { - let proxy_ident = &proxy_type.proxy_ident; - let arg_name = & self.arg_name; - quote_spanned!{self.span=> - #proxy_ident::new(#arg_name) - } - } - - fn visit_type(&mut self, _type: &Type, _: bool) -> proc_macro2::TokenStream { - self.arg_name.to_token_stream() - } - + .into() } \ No newline at end of file diff --git a/languages/bevy_mod_scripting_lua_derive/src/visitor.rs b/languages/bevy_mod_scripting_lua_derive/src/visitor.rs new file mode 100644 index 0000000000..4ffb569610 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/src/visitor.rs @@ -0,0 +1,357 @@ +/// This module contains both `SimpleType` and `syn::Type` visitors to help us with the code generation. +use bevy_mod_scripting_common::input::*; +use proc_macro2::Span; +use proc_macro_error::*; +use quote::*; +use syn::*; + +/// Generates an unwrapping expression which can be used to assign the unwrapped proxy to a variable. +/// for example for the type `MyType` with `__proxied_out` identifier +/// the argument `#[proxy] MyType` will generate the following expression: +/// ```rust,ignore +/// let __proxied_out : MyType = other.inner()?; +/// ``` +pub(crate) struct LuaSimpleTypeArgumentUnwrapper { + arg_name: Ident, + span: Span, +} + +impl LuaSimpleTypeArgumentUnwrapper { + pub fn new(arg_name: Ident, span: Span) -> Self { + Self { arg_name, span } + } +} + +impl VisitSimpleType for LuaSimpleTypeArgumentUnwrapper { + fn visit_unit(&mut self, _: bool) -> proc_macro2::TokenStream { + quote_spanned!(self.span=> ()) + } + + fn visit_proxy_type( + &mut self, + _: &ProxyType, + is_child_of_reference: bool, + ) -> proc_macro2::TokenStream { + let arg_name: &Ident = &self.arg_name; + + if is_child_of_reference { + quote_spanned!(self.span=> #arg_name) + } else { + quote_spanned!(self.span=> #arg_name.inner()?) + } + } + + fn visit_type(&mut self, _type: &Type, _: bool) -> proc_macro2::TokenStream { + let arg_name: &Ident = &self.arg_name; + quote_spanned!(self.span=> #arg_name) + } + + fn visit_unit_path(&mut self, unit_path: &UnitPath, _: bool) -> proc_macro2::TokenStream { + match unit_path.std_type_ident { + Some(StdTypeIdent::Option) => { + let inner = self.visit_simple_type(&unit_path.inner, false); + let arg_name = &self.arg_name; + quote_spanned!(self.span=> + #arg_name.map(|#arg_name| Ok::<_,bevy_mod_scripting_lua::tealr::mlu::mlua::Error>(#inner)).transpose()? + ) + } + Some(StdTypeIdent::Vec) => { + let inner = self.visit_simple_type(&unit_path.inner, false); + let arg_name = &self.arg_name; + quote_spanned!(self.span=> + #arg_name.into_iter().map(|#arg_name| Ok(#inner)).collect::,bevy_mod_scripting_lua::tealr::mlu::mlua::Error>>()? + ) + } + Some(unsupported_std_type) => abort!( + unit_path.ident, + "`{}` is not yet supported", + unsupported_std_type + ), + _ => abort!(unit_path.ident, "Unsupported type"), + } + } +} + +/// `maps` a simple type recursively, expanding the type into a series of map/iter/etc calls where the leaf types are operating over +/// unwrapped proxied types (the inner types) and the output expression produces a wrapped proxy type. +/// +/// requires arg_name to be a valid identifier refering to the name of the variable containing a value with the SimpleType being mapped. +/// The returned token stream will be an expression. +pub(crate) struct LuaSimpleTypeWrapper { + arg_name: Ident, + span: Span, +} + +impl LuaSimpleTypeWrapper { + pub fn new(arg_name: Ident, span: Span) -> Self { + Self { arg_name, span } + } +} + +impl VisitSimpleType for LuaSimpleTypeWrapper { + fn visit_unit_path(&mut self, unit_path: &UnitPath, _: bool) -> proc_macro2::TokenStream { + match unit_path.std_type_ident { + Some(StdTypeIdent::Option) => { + let inner = self.visit_simple_type(&unit_path.inner, false); + let arg_name = &self.arg_name; + quote_spanned!(self.span=> + #arg_name.map(|#arg_name| #inner) + ) + } + Some(StdTypeIdent::Vec) => { + let inner = self.visit_simple_type(&unit_path.inner, false); + let arg_name = &self.arg_name; + + quote_spanned!(self.span=> + #arg_name.into_iter().map(|#arg_name| #inner).collect::>() + ) + } + Some(unsupported_std_type) => abort!( + unit_path.ident, + "`{}` is not yet supported", + unsupported_std_type + ), + _ => abort!(unit_path.ident, "Unsupported type"), + } + } + + fn visit_duo_path(&mut self, duo_path: &DuoPath, _: bool) -> proc_macro2::TokenStream { + let tealr = quote!(bevy_mod_scripting_lua::tealr); + + match duo_path.std_type_ident { + Some(StdTypeIdent::Result) => { + let left = self.visit_simple_type(&duo_path.left, false); + let right = self.visit_simple_type(&duo_path.right, false); + let arg_name = &self.arg_name; + quote_spanned!(self.span=> + #arg_name.map(|#arg_name| #left).map_err(|#arg_name| #tealr::mlu::mlua::Error::external(#right)) + ) + } + Some(unsupported_std_type) => abort!( + duo_path.ident, + "`{}` is not yet supported", + unsupported_std_type + ), + _ => abort!(duo_path.ident, "Unsupported type"), + } + } + + fn visit_unit(&mut self, _: bool) -> proc_macro2::TokenStream { + quote_spanned!(self.span=> + () + ) + } + + fn visit_proxy_type(&mut self, proxy_type: &ProxyType, _: bool) -> proc_macro2::TokenStream { + let proxy_ident = &proxy_type.proxy_ident; + let arg_name = &self.arg_name; + quote_spanned! {self.span=> + #proxy_ident::new(#arg_name) + } + } + + fn visit_type(&mut self, _type: &Type, _: bool) -> proc_macro2::TokenStream { + self.arg_name.to_token_stream() + } +} + +/// Wrapper around the `TypeConstructorVisitor` which generates a syn::Type from a `SimpleType`. +/// This is used to handle special cases such as when encountering an outer `Result` where E needs to specifically be converted to an `mlua::Error` on the proxy side +pub(crate) struct LuaTypeConstructorVisitor { + pub general_visitor: TypeConstructorVisitor, +} + +impl LuaTypeConstructorVisitor { + pub fn new(generate_proxy_type: bool, strip_outer_ref: bool) -> Self { + Self { + general_visitor: TypeConstructorVisitor::new(generate_proxy_type, strip_outer_ref), + } + } +} + +impl VisitSimpleType for LuaTypeConstructorVisitor { + fn visit_unit(&mut self, is_child_of_reference: bool) -> Type { + self.general_visitor.visit_unit(is_child_of_reference) + } + + fn visit_proxy_type(&mut self, proxy_type: &ProxyType, is_child_of_reference: bool) -> Type { + self.general_visitor + .visit_proxy_type(proxy_type, is_child_of_reference) + } + + fn visit_type(&mut self, _type: &Type, is_child_of_reference: bool) -> Type { + self.general_visitor + .visit_type(_type, is_child_of_reference) + } + + fn visit_unit_path(&mut self, unit_path: &UnitPath, is_child_of_reference: bool) -> Type { + self.general_visitor + .visit_unit_path(unit_path, is_child_of_reference) + } + + fn visit_duo_path(&mut self, duo_path: &DuoPath, is_child_of_reference: bool) -> Type { + // this will only trigger for top level types, the deeper nesting is handled by the general visitor + // outer Result needs to be converted to Result when converting to a proxy_type + let tealr = quote!(bevy_mod_scripting_lua::tealr); + + if duo_path + .std_type_ident + .is_some_and(|i| i == StdTypeIdent::Result) + && self.general_visitor.generate_proxy_type + { + let ident = &duo_path.ident; + let lt_token = duo_path.lt_token; + let gt_token = duo_path.gt_token; + let left = self.visit_simple_type(&duo_path.left, false); + parse_quote!(#ident #lt_token #left, #tealr::mlu::mlua::Error #gt_token) + } else { + self.general_visitor + .visit_duo_path(duo_path, is_child_of_reference) + } + } + + fn visit_reference( + &mut self, + reference: &bevy_mod_scripting_common::input::Reference, + is_child_of_reference: bool, + ) -> Type { + self.general_visitor + .visit_reference(reference, is_child_of_reference) + } +} + +#[cfg(test)] +mod test { + use std::collections::HashMap; + + use crate::visitor::LuaSimpleTypeArgumentUnwrapper; + + use super::LuaSimpleTypeWrapper; + use bevy_mod_scripting_common::input::{SimpleType, VisitSimpleType}; + use proc_macro2::Span; + use quote::*; + use syn::parse_quote; + + #[test] + pub fn test_lua_argument_wrapper_simple_proxy() { + let expected = quote_spanned!(Span::call_site()=> + LuaMyType::new(arg) + ); + + let mut visitor = LuaSimpleTypeWrapper::new(format_ident!("arg"), Span::call_site()); + + let output = visitor.visit( + &SimpleType::new_from_fully_specified_type( + "Lua", + &parse_quote!(MyType), + &HashMap::from_iter([(format_ident!("MyType"), None)]), + ) + .unwrap(), + ); + + assert_eq!(output.to_string(), expected.to_string()) + } + + #[test] + pub fn test_lua_argument_wrapper_non_proxy() { + let expected = quote_spanned!(Span::call_site()=> + arg + ); + + let mut visitor = LuaSimpleTypeWrapper::new(format_ident!("arg"), Span::call_site()); + + let output = visitor.visit( + &SimpleType::new_from_fully_specified_type( + "Lua", + &parse_quote!(MyType), + &HashMap::from_iter([]), + ) + .unwrap(), + ); + + assert_eq!(output.to_string(), expected.to_string()) + } + + #[test] + pub fn test_lua_argument_wrapper_vec() { + let expected = quote_spanned!(Span::call_site()=> + arg.into_iter().map(|arg| LuaMyType::new(arg)).collect::>() + ); + + let mut visitor = LuaSimpleTypeWrapper::new(format_ident!("arg"), Span::call_site()); + + let output = visitor.visit( + &SimpleType::new_from_fully_specified_type( + "Lua", + &parse_quote!(Vec), + &HashMap::from_iter([(format_ident!("MyType"), None)]), + ) + .unwrap(), + ); + + assert_eq!(output.to_string(), expected.to_string()) + } + + #[test] + pub fn test_lua_argument_unwrapper_simple_proxy() { + let expected = quote_spanned!(Span::call_site()=> + arg.inner()? + ); + + let mut visitor = + LuaSimpleTypeArgumentUnwrapper::new(format_ident!("arg"), Span::call_site()); + + let output = visitor.visit( + &SimpleType::new_from_fully_specified_type( + "Lua", + &parse_quote!(MyType), + &HashMap::from_iter([(format_ident!("MyType"), None)]), + ) + .unwrap(), + ); + + assert_eq!(output.to_string(), expected.to_string()) + } + + #[test] + pub fn test_lua_argument_unwrapper_non_proxy() { + let expected = quote_spanned!(Span::call_site()=> + arg + ); + + let mut visitor = + LuaSimpleTypeArgumentUnwrapper::new(format_ident!("arg"), Span::call_site()); + + let output = visitor.visit( + &SimpleType::new_from_fully_specified_type( + "Lua", + &parse_quote!(MyType), + &HashMap::from_iter([]), + ) + .unwrap(), + ); + + assert_eq!(output.to_string(), expected.to_string()) + } + + #[test] + pub fn test_lua_argument_unwrapper_vec() { + let expected = quote_spanned!(Span::call_site()=> + arg.into_iter().map(|arg| Ok(arg.inner()?)).collect::, bevy_mod_scripting_lua::tealr::mlu::mlua::Error>>()? + ); + + let mut visitor = + LuaSimpleTypeArgumentUnwrapper::new(format_ident!("arg"), Span::call_site()); + + let output = visitor.visit( + &SimpleType::new_from_fully_specified_type( + "Lua", + &parse_quote!(Vec), + &HashMap::from_iter([(format_ident!("MyType"), None)]), + ) + .unwrap(), + ); + + assert_eq!(output.to_string(), expected.to_string()) + } +} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/references/non-proxy-reference.rs b/languages/bevy_mod_scripting_lua_derive/tests/fail/references/non-proxy-reference.rs new file mode 100644 index 0000000000..11ea76cd81 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/references/non-proxy-reference.rs @@ -0,0 +1,23 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(Function)] + fn fn_returning_some_string(some_str: &str) -> String; + +]] +#[derive(Clone)] +pub struct MyStruct { + some_string: String, + me_vec: Vec, +} + +impl MyStruct { + pub fn fn_returning_some_string(some_str: &str) -> String { + some_str.to_owned() + } +} + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/references/non-proxy-reference.stderr b/languages/bevy_mod_scripting_lua_derive/tests/fail/references/non-proxy-reference.stderr new file mode 100644 index 0000000000..57e898817a --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/references/non-proxy-reference.stderr @@ -0,0 +1,23 @@ +error[E0277]: the trait bound `&str: LuaUserData` is not satisfied + --> tests/fail/references/non-proxy-reference.rs:7:5 + | +7 | #[lua(Function)] + | ^ the trait `LuaUserData` is not implemented for `&str` + | + = help: the following other types implement trait `LuaUserData`: + Arc> + Arc> + LuaAabb + LuaAlignContent + LuaAlignItems + LuaAlignSelf + LuaAlphaMode + LuaAmbientLight + and $N others + = note: required for `&str` to implement `FromLua<'_>` + = note: required for `&str` to implement `FromLuaMulti<'lua>` +note: required by a bound in `bevy_mod_scripting_lua::tealr::mlu::TealDataMethods::add_function` + --> $CARGO/tealr-0.9.0-alpha4/src/mlu/teal_data_methods.rs + | + | A: FromLuaMulti<'lua> + TealMultiValue, + | ^^^^^^^^^^^^^^^^^^ required by this bound in `TealDataMethods::add_function` diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/references/output-with-proxy-reference.rs b/languages/bevy_mod_scripting_lua_derive/tests/fail/references/output-with-proxy-reference.rs new file mode 100644 index 0000000000..4e0cbfbefd --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/references/output-with-proxy-reference.rs @@ -0,0 +1,15 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(Function, output(proxy))] + fn fn_returning_some_string(#[proxy] ref_: &Self ) -> &Self { + ref_ + } +]] +#[derive(Clone)] +pub struct MyStruct; + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/references/output-with-proxy-reference.stderr b/languages/bevy_mod_scripting_lua_derive/tests/fail/references/output-with-proxy-reference.stderr new file mode 100644 index 0000000000..60ef325f26 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/references/output-with-proxy-reference.stderr @@ -0,0 +1,5 @@ +error: Lua proxy functions do not support non 'static types as return values yet + --> tests/fail/references/output-with-proxy-reference.rs:8:59 + | +8 | fn fn_returning_some_string(#[proxy] ref_: &Self ) -> &Self { + | ^ diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/function-with-receiver.rs b/languages/bevy_mod_scripting_lua_derive/tests/fail/simple/function-with-receiver.rs similarity index 100% rename from languages/bevy_mod_scripting_lua_derive/tests/fail/function-with-receiver.rs rename to languages/bevy_mod_scripting_lua_derive/tests/fail/simple/function-with-receiver.rs diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/function-with-receiver.stderr b/languages/bevy_mod_scripting_lua_derive/tests/fail/simple/function-with-receiver.stderr similarity index 75% rename from languages/bevy_mod_scripting_lua_derive/tests/fail/function-with-receiver.stderr rename to languages/bevy_mod_scripting_lua_derive/tests/fail/simple/function-with-receiver.stderr index f7f26b6034..6e0c490b92 100644 --- a/languages/bevy_mod_scripting_lua_derive/tests/fail/function-with-receiver.stderr +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/simple/function-with-receiver.stderr @@ -1,11 +1,11 @@ error: Lua proxy functions of type: Function, do not expect a receiver argument - --> tests/fail/function-with-receiver.rs:8:33 + --> tests/fail/simple/function-with-receiver.rs:8:33 | 8 | fn fn_returning_some_string(self) { | ^^^^ error: Lua proxy functions of type: Function, do not expect a receiver argument - --> tests/fail/function-with-receiver.rs:13:27 + --> tests/fail/simple/function-with-receiver.rs:13:27 | 13 | fn fn_returning_proxy(&self) { | ^^^^^ diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-count.rs b/languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-argument-count.rs similarity index 100% rename from languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-count.rs rename to languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-argument-count.rs diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-count.stderr b/languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-argument-count.stderr similarity index 77% rename from languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-count.stderr rename to languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-argument-count.stderr index 0d8433bc45..48012bcbaa 100644 --- a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-count.stderr +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-argument-count.stderr @@ -1,11 +1,11 @@ error[E0061]: this method takes 1 argument but 0 arguments were supplied - --> tests/fail/invalid-argument-count.rs:8:8 + --> tests/fail/simple/invalid-argument-count.rs:8:8 | 8 | fn my_fn(&self); | ^^^^^------- an argument of type `usize` is missing | note: method defined here - --> tests/fail/invalid-argument-count.rs:14:12 + --> tests/fail/simple/invalid-argument-count.rs:14:12 | 14 | pub fn my_fn(&self, _: usize) {} | ^^^^^ -------- diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-type.rs b/languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-argument-type.rs similarity index 100% rename from languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-type.rs rename to languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-argument-type.rs diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-type.stderr b/languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-argument-type.stderr similarity index 74% rename from languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-type.stderr rename to languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-argument-type.stderr index 912e96cf75..f88ac24e24 100644 --- a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-argument-type.stderr +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-argument-type.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> tests/fail/invalid-argument-type.rs:8:21 + --> tests/fail/simple/invalid-argument-type.rs:8:21 | 8 | fn my_fn(&self, arg: String); | ----- ^^^ expected `usize`, found `String` @@ -7,7 +7,7 @@ error[E0308]: mismatched types | arguments to this method are incorrect | note: method defined here - --> tests/fail/invalid-argument-type.rs:14:12 + --> tests/fail/simple/invalid-argument-type.rs:14:12 | 14 | pub fn my_fn(&self, _: usize) {} | ^^^^^ -------- diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-function-type.rs b/languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-function-type.rs similarity index 100% rename from languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-function-type.rs rename to languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-function-type.rs diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-function-type.stderr b/languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-function-type.stderr similarity index 81% rename from languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-function-type.stderr rename to languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-function-type.stderr index 296351d86f..d63f71a938 100644 --- a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-function-type.stderr +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-function-type.stderr @@ -1,5 +1,5 @@ error: Invalid Function Type, expected one of: Function, MetaFunction, Method, MetaMethod, MutableFunction, MutableMetaFunction, MutatingMethod, MutatingMetaMethod - --> tests/fail/invalid-function-type.rs:7:11 + --> tests/fail/simple/invalid-function-type.rs:7:11 | 7 | #[lua(AMASJDIASDKAW)] | ^^^^^^^^^^^^^ diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type-custom-body.rs b/languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-output-type-custom-body.rs similarity index 100% rename from languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type-custom-body.rs rename to languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-output-type-custom-body.rs diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type-custom-body.stderr b/languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-output-type-custom-body.stderr similarity index 72% rename from languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type-custom-body.stderr rename to languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-output-type-custom-body.stderr index 64e9f589a6..74c91fc804 100644 --- a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type-custom-body.stderr +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-output-type-custom-body.stderr @@ -1,5 +1,5 @@ error: Did not expect contextual receiver in constructing simple proxy type - --> tests/fail/invalid-output-type-custom-body.rs:8:32 + --> tests/fail/simple/invalid-output-type-custom-body.rs:8:32 | 8 | fn fn_returning_proxy() -> Self { | ^^^^ diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type.rs b/languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-output-type.rs similarity index 100% rename from languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type.rs rename to languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-output-type.rs diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type.stderr b/languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-output-type.stderr similarity index 77% rename from languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type.stderr rename to languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-output-type.stderr index 7d6ef913fc..08235e6c47 100644 --- a/languages/bevy_mod_scripting_lua_derive/tests/fail/invalid-output-type.stderr +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/simple/invalid-output-type.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> tests/fail/invalid-output-type.rs:8:8 + --> tests/fail/simple/invalid-output-type.rs:8:8 | 8 | fn my_fn() -> usize; | ^^^^^^^ ----- expected due to this diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/method-without-receiver.rs b/languages/bevy_mod_scripting_lua_derive/tests/fail/simple/method-without-receiver.rs similarity index 100% rename from languages/bevy_mod_scripting_lua_derive/tests/fail/method-without-receiver.rs rename to languages/bevy_mod_scripting_lua_derive/tests/fail/simple/method-without-receiver.rs diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/method-without-receiver.stderr b/languages/bevy_mod_scripting_lua_derive/tests/fail/simple/method-without-receiver.stderr similarity index 72% rename from languages/bevy_mod_scripting_lua_derive/tests/fail/method-without-receiver.stderr rename to languages/bevy_mod_scripting_lua_derive/tests/fail/simple/method-without-receiver.stderr index 3724381ad1..5b4b01362a 100644 --- a/languages/bevy_mod_scripting_lua_derive/tests/fail/method-without-receiver.stderr +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/simple/method-without-receiver.stderr @@ -1,11 +1,11 @@ error: Lua proxy functions of type: Method, require `self` argument - --> tests/fail/method-without-receiver.rs:8:25 + --> tests/fail/simple/method-without-receiver.rs:8:25 | 8 | fn fn_taking_nothing() { | ^^ error: Lua proxy functions of type: Method, require `self` argument - --> tests/fail/method-without-receiver.rs:13:23 + --> tests/fail/simple/method-without-receiver.rs:13:23 | 13 | fn fn_taking_usize(arg: usize) { | ^^^^^^^^^^^^ diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/missing-proxy-output-attr.rs b/languages/bevy_mod_scripting_lua_derive/tests/fail/simple/missing-proxy-output-attr.rs similarity index 100% rename from languages/bevy_mod_scripting_lua_derive/tests/fail/missing-proxy-output-attr.rs rename to languages/bevy_mod_scripting_lua_derive/tests/fail/simple/missing-proxy-output-attr.rs diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/missing-proxy-output-attr.stderr b/languages/bevy_mod_scripting_lua_derive/tests/fail/simple/missing-proxy-output-attr.stderr similarity index 73% rename from languages/bevy_mod_scripting_lua_derive/tests/fail/missing-proxy-output-attr.stderr rename to languages/bevy_mod_scripting_lua_derive/tests/fail/simple/missing-proxy-output-attr.stderr index b8996fa02e..11f15b1c0f 100644 --- a/languages/bevy_mod_scripting_lua_derive/tests/fail/missing-proxy-output-attr.stderr +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/simple/missing-proxy-output-attr.stderr @@ -1,5 +1,5 @@ error: Did not expect contextual receiver in constructing simple proxy type - --> tests/fail/missing-proxy-output-attr.rs:8:32 + --> tests/fail/simple/missing-proxy-output-attr.rs:8:32 | 8 | fn fn_returning_proxy() -> Self { | ^^^^ diff --git a/languages/bevy_mod_scripting_lua_derive/tests/success/containers/option-argument.rs b/languages/bevy_mod_scripting_lua_derive/tests/success/containers/option-argument.rs new file mode 100644 index 0000000000..3d773c5a82 --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/success/containers/option-argument.rs @@ -0,0 +1,20 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect, Clone)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(Function)] + fn fn_returning_string_option(_opt: Option) { + + } + + + #[lua(Function)] + fn fn_returning_some_proxy(#[proxy] _opt: Option) { + + } +]] +pub struct MyStruct; + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/success/containers/option.rs b/languages/bevy_mod_scripting_lua_derive/tests/success/containers/option-output.rs similarity index 100% rename from languages/bevy_mod_scripting_lua_derive/tests/success/containers/option.rs rename to languages/bevy_mod_scripting_lua_derive/tests/success/containers/option-output.rs diff --git a/languages/bevy_mod_scripting_lua_derive/tests/success/containers/vec-argument.rs b/languages/bevy_mod_scripting_lua_derive/tests/success/containers/vec-argument.rs new file mode 100644 index 0000000000..e1b9445dfe --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/success/containers/vec-argument.rs @@ -0,0 +1,19 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect, Clone)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(Function)] + fn fn_returning_string_vec(_vec: Vec) { + } + + #[lua(Function)] + fn fn_returning_proxy_vec(#[proxy] _vec: Vec) { + + } + +]] +pub struct MyStruct; + +pub fn main() {} diff --git a/languages/bevy_mod_scripting_lua_derive/tests/success/containers/vec.rs b/languages/bevy_mod_scripting_lua_derive/tests/success/containers/vec-output.rs similarity index 100% rename from languages/bevy_mod_scripting_lua_derive/tests/success/containers/vec.rs rename to languages/bevy_mod_scripting_lua_derive/tests/success/containers/vec-output.rs diff --git a/languages/bevy_mod_scripting_lua_derive/tests/success/references/proxy-non-receiver-reference.rs b/languages/bevy_mod_scripting_lua_derive/tests/success/references/proxy-non-receiver-reference.rs new file mode 100644 index 0000000000..224462dc5e --- /dev/null +++ b/languages/bevy_mod_scripting_lua_derive/tests/success/references/proxy-non-receiver-reference.rs @@ -0,0 +1,23 @@ +use bevy::prelude::*; +use bevy_mod_scripting::api::*; + +#[derive(ScriptProxy, Reflect)] +#[proxy(languages("lua"), derive(Clone))] +#[functions[ + #[lua(Function)] + fn fn_returning_some_string(#[proxy] other: &Self) -> String; + +]] +#[derive(Clone)] +pub struct MyStruct { + some_string: String, + me_vec: Vec, +} + +impl MyStruct { + pub fn fn_returning_some_string(other: &Self) -> String { + other.some_string.clone() + } +} + +pub fn main() {} From b2a9a8d47c3f0839fe734a296a19f4501eb737af Mon Sep 17 00:00:00 2001 From: makspll Date: Fri, 14 Jul 2023 16:39:25 +0100 Subject: [PATCH 16/94] update wrappers.rs example --- examples/wrappers.rs | 239 +++--------------- .../bevy_mod_scripting_lua_derive/src/lib.rs | 28 +- 2 files changed, 62 insertions(+), 205 deletions(-) diff --git a/examples/wrappers.rs b/examples/wrappers.rs index 01e933ac62..5ee08cad2d 100644 --- a/examples/wrappers.rs +++ b/examples/wrappers.rs @@ -18,228 +18,62 @@ impl Display for MyError { impl Error for MyError {} -// Step 1. Rust representation -// construct all our types and functionality -// Reflect is neccessary to allow access from scripts -// Clone allows receiving our wrapper as a function parameter (derives FromLua via UserData through mlua's traits) -// We can still use references to NonClone wrappers via AnyUserData in lua methods. -// Even though we are implementing Clone we are still able to reference the original data in script thanks to the script wrapper we are about to implement -// Debug is nice to have, we can forward that implementation to Lua's ToString via our macro -#[derive(Resource, Reflect, Default, Clone, Debug)] -#[reflect(Resource)] -pub struct MyThing { - usize: usize, - string: String, -} - -#[derive(ScriptProxy, Reflect)] +#[derive(ScriptProxy, Reflect, Resource, Default, Debug)] +#[reflect(Resource, LuaProxyable)] #[proxy(languages("on_feature(lua)"), derive(Clone))] #[functions[ - + #[lua(MutatingMethod)] + fn set_my_string(&mut self, another_string: Option); - #[lua(Function)] - fn fn_taking_option(#[proxy] some_str: Option) { - - } - - #[lua(Function)] - fn fn_taking_vec(#[proxy] some_str: Vec) { + #[lua(MetaMethod)] + fn ToString(&self) -> String { + format!("{:#?}", _self) } - - #[lua(Method, output(proxy))] - fn fn_returning_vec_of_self_(self, #[proxy] other: &Self) -> Vec { - vec![other.clone()] - } - - #[lua(Method, output(proxy))] - fn fn_returning_vec_of_self(self) -> Vec { - vec![_self] - } - - #[lua(Method, output(proxy))] - fn fn_returning_vec(self) -> Vec; - - #[lua(Method, output(proxy))] - fn fn_returning_result(self) -> Result:: { - // let a = self.some_string; - // Ok(Lol{ - // some_string: a - // }) - Err(MyError) - } - - #[lua(Method, output(proxy))] - fn fn_returning_option(self) -> Option:: { - let a = self.some_string; - Some(Lol{ - some_string: a, - me_vec: Default::default(), - }) - // None - } - - - #[lua(Method, output(proxy))] - fn custom_body(self) -> Self { - let a = self.some_string; - Lol{ - some_string: a, - me_vec: Default::default(), - } - } - - #[lua(Method, output(proxy))] - fn fn_over_self_and_another(self, #[proxy] another: &Self) -> Self; - - #[lua(Function)] - fn fn_over_string_returning_string(a : String) -> String; - - #[lua(Function)] - fn fn_over_string(a : String); - - #[lua(Method,output(proxy))] - fn fn_over_self_ref(&self) -> Lol; - - #[lua(MutatingMethod,output(proxy))] - fn fn_over_self_ref_mut(&mut self) -> Lol; ]] #[derive(Clone)] -pub struct Lol { - some_string: String, - me_vec: Vec, +pub struct MyProxiedStruct { + my_string: String, } -impl Lol { - pub fn fn_returning_vec(&self) -> Vec { - self.me_vec.clone() - } - - pub fn fn_returning_result(self) -> Result { - Ok(self) - } - - pub fn fn_returning_option(self) -> Option { - Some(self) - } - - pub fn fn_over_self_and_another(self, another: &Self) -> Self { - Self { - some_string: "lol".to_owned(), - me_vec: Default::default(), - } - } - - pub fn fn_over_string(_: String) {} - - pub fn fn_over_string_returning_string(str_: String) -> String { - str_ - } - - pub fn fn_over_self_ref(&self) -> Self { - Self { - some_string: "lol".to_owned(), - me_vec: Default::default(), - } - } - - pub fn fn_over_self_ref_mut(&mut self) -> Self { - Self { - some_string: "lol".to_owned(), - me_vec: Default::default(), +impl MyProxiedStruct { + fn set_my_string(&mut self, another_string: Option) { + if let Some(s) = another_string { + self.my_string = s; + } else { + self.my_string = "".to_owned(); } } } -impl MyThing { - pub fn do_something_cool(&self) -> String { - self.string.clone() - } -} - -impl MyThing { - pub fn hello(&self) {} -} -// Step 2. Script representation -// this macro does some magic and provides you with a `LuaMyThing` (and possibly more for other enabled languages) type with which you can create: -// - owned values of your type via ::new() -// - references to something in the world (or script) via ::new_ref() and the ScriptRef API -// (however this is only really accessible given the world provided to the script via the script host) -// Script references can also be made to subfields (even non reflectable ones) of types via sub reflection -// -// Note: this step is not fully necessary, if your value is reflectable, you'll be able to reach it via -// The bevy API, however doing this means your provide static typing for your scripts in languages which support it, -// To see what else this macro can do see `src/api/generated.rs` -impl_script_newtype!( - #[languages(lua)] - MyThing: - Debug + Clone - + Fields( - /// My usize field - usize: Raw(usize), - /// My string field - string: Raw(String) - - ) + Methods( - /// Does something realy cool! - /// this documentation gets forwarded to any utilities provided by the script host wooo - do_something_cool(&self:) - ) - - lua impl { - // we can also directly add methods to the underlying script traits using their specific syntax - // note that in this case you need to provide an implementation for every language you want to support, - // the flags above automatically do this for you. - - // below is a custom lua function - // the fn here means this is a function and not a method (no self argument) - // normally you'd make these available globally via mlua::create_proxy, but I digress. - fn "make_ref_to_my_resource" => |ctx,()| { - let globals = ctx.globals(); - let lua_world : LuaWorld = globals.get("world")?; - let mut world = lua_world.write(); - - let reflect_resource_data = world.resource_scope(|world, type_registry: Mut| { - let type_registry = type_registry.read(); - let data = type_registry.get_type_data::(std::any::TypeId::of::()).expect("Type not registered properly"); - data.clone() - }); - - // this is absolutely safe! - Ok(LuaMyThing::new_ref(ScriptRef::new_resource_ref(reflect_resource_data, lua_world.as_ref().clone()))) - }; - } - -); - fn main() -> std::io::Result<()> { let mut app = App::new(); app.add_plugins(DefaultPlugins) .add_plugin(ScriptingPlugin) - .add_script_host_to_base_set::, _>(CoreSet::PostUpdate) - .register_type::() - .init_resource::() + .add_script_host_to_base_set::, _>(CoreSet::PostUpdate) + .register_type::() + .init_resource::() + .add_api_provider::>(Box::new(LuaBevyAPIProvider)) .add_system(|world: &mut World| { - world.insert_resource(MyThing { - usize: 420, - string: "I live in the bevy world, you can't touch me!".to_owned(), + world.insert_resource(MyProxiedStruct { + my_string: "I was retrieved from the world".to_owned(), }); // run script - world.resource_scope(|world, mut host: Mut>| { + world.resource_scope(|world, mut host: Mut>| { host.run_one_shot( r#" - function once(my_thing) - local my_thing2 = my_thing.make_ref_to_my_resource() - print(my_thing2) - print(my_thing2.usize) - print(my_thing2.string) - print(my_thing2:do_something_cool()) + function once() + local type = world:get_type_by_name("MyProxiedStruct") + local resource = world:get_resource(type) - my_thing2.usize = my_thing.usize - my_thing2.string = my_thing.string + print("The initial value is:", resource) + print("The string value is:", resource.my_string) + + resource:set_my_string(nil) + print("The string value after calling method is:", resource.my_string) - print(my_thing2:do_something_cool()) + resource:set_my_string("I was changed by the script") end "# .as_bytes(), @@ -248,10 +82,7 @@ fn main() -> std::io::Result<()> { world, LuaEvent { hook_name: "once".to_owned(), - args: LuaMyThing::new(MyThing { - usize: 42, - string: "Haha! Yes I can!!!!".to_owned(), - }), + args: (), recipients: Recipients::All, }, ) @@ -260,9 +91,9 @@ fn main() -> std::io::Result<()> { // print current state of MyThing let my_thing = world - .get_resource::() - .expect("Could not find MyThing Resource"); - println!("After script run: {my_thing:#?}"); + .get_resource::() + .expect("Could not find MyProxiedStruct Resource"); + println!("After the script MyProxiedStruct resource is now: {my_thing:#?}"); // exit app world.send_event(AppExit) }); diff --git a/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/languages/bevy_mod_scripting_lua_derive/src/lib.rs index f714f0696a..a94f0f2298 100644 --- a/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -702,7 +702,6 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { #[automatically_derived] #[allow(unused_parens,unused_braces,unused_mut)] #[allow(clippy::all)] - impl #tealr::mlu::TealData for #proxy_type { fn add_methods<'lua, T: #tealr::mlu::TealDataMethods<'lua, Self>>(methods: &mut T) { #(#type_level_document_calls)* @@ -714,6 +713,33 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { } } + #[allow(clippy::all)] + impl bevy_script_api::lua::LuaProxyable for #proxied_name { + fn ref_to_lua<'lua>(self_ : bevy_script_api::script_ref::ScriptRef, lua: &'lua #tealr::mlu::mlua::Lua) -> #tealr::mlu::mlua::Result<#tealr::mlu::mlua::Value<'lua>> { + <#proxy_type as #tealr::mlu::mlua::ToLua>::to_lua(#proxy_type::new_ref(self_),lua) + } + + fn apply_lua<'lua>(self_ : &mut bevy_script_api::script_ref::ScriptRef, lua: &'lua #tealr::mlu::mlua::Lua, new_val: #tealr::mlu::mlua::Value<'lua>) -> #tealr::mlu::mlua::Result<()> { + if let #tealr::mlu::mlua::Value::UserData(v) = new_val { + let other = v.borrow::<#proxy_type>()?; + let other = &other; + + other.apply_self_to_base(self_)?; + Ok(()) + } else { + Err(#tealr::mlu::mlua::Error::RuntimeError( + "Error in assigning to custom user data".to_owned(), + )) + } + } + } + + impl bevy_script_api::lua::ToLuaProxy<'_> for #proxied_name { + fn to_lua_proxy<'lua>(self, lua: &'lua #tealr::mlu::mlua::Lua) -> #tealr::mlu::mlua::Result<#tealr::mlu::mlua::Value<'lua>>{ + <#proxy_type as #tealr::mlu::mlua::ToLua>::to_lua(#proxy_type::new(self),lua) + } + } + } .into() } \ No newline at end of file From 0497658660827204ed24a6226218a0cae1449009 Mon Sep 17 00:00:00 2001 From: makspll Date: Sat, 15 Jul 2023 13:28:25 +0100 Subject: [PATCH 17/94] correct example --- examples/wrappers.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/examples/wrappers.rs b/examples/wrappers.rs index 5ee08cad2d..9b72c673f1 100644 --- a/examples/wrappers.rs +++ b/examples/wrappers.rs @@ -25,6 +25,10 @@ impl Error for MyError {} #[lua(MutatingMethod)] fn set_my_string(&mut self, another_string: Option); + #[lua(Method)] + fn get_my_string(&self) -> String; + + #[lua(MetaMethod)] fn ToString(&self) -> String { format!("{:#?}", _self) @@ -43,6 +47,10 @@ impl MyProxiedStruct { self.my_string = "".to_owned(); } } + + fn get_my_string(&self) -> String { + self.my_string.clone() + } } fn main() -> std::io::Result<()> { @@ -68,11 +76,10 @@ fn main() -> std::io::Result<()> { local resource = world:get_resource(type) print("The initial value is:", resource) - print("The string value is:", resource.my_string) + print("The string value is:", resource:get_my_string()) resource:set_my_string(nil) - print("The string value after calling method is:", resource.my_string) - + print("The string value after calling method is:", resource:get_my_string()) resource:set_my_string("I was changed by the script") end "# From fabecc50fe2284cc4419610aebcc3c36ebd55ad7 Mon Sep 17 00:00:00 2001 From: makspll Date: Sat, 15 Jul 2023 13:32:55 +0100 Subject: [PATCH 18/94] add more to wrappers.rs --- examples/wrappers.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/wrappers.rs b/examples/wrappers.rs index 9b72c673f1..beb1db17dd 100644 --- a/examples/wrappers.rs +++ b/examples/wrappers.rs @@ -79,8 +79,11 @@ fn main() -> std::io::Result<()> { print("The string value is:", resource:get_my_string()) resource:set_my_string(nil) - print("The string value after calling method is:", resource:get_my_string()) + print("The string value after calling method with nil is:", resource:get_my_string()) + resource:set_my_string("I was changed by the script") + print("The string value after calling method with string is:", resource:get_my_string()) + end "# .as_bytes(), From 6c3db0284f69cb5d3be637bb644458153f15ddaa Mon Sep 17 00:00:00 2001 From: makspll Date: Thu, 24 Aug 2023 08:53:51 +0100 Subject: [PATCH 19/94] rename wrappers.rs --- Cargo.toml | 59 +++++++++++------------ examples/{wrappers.rs => new_wrappers.rs} | 0 2 files changed, 28 insertions(+), 31 deletions(-) rename examples/{wrappers.rs => new_wrappers.rs} (100%) diff --git a/Cargo.toml b/Cargo.toml index cb4aeb47e0..b57f885480 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ homepage = "https://github.com/makspll/bevy_mod_scripting" keywords = ["bevy", "gamedev", "scripting", "lua"] categories = ["game-development"] readme = "readme.md" -include= ["readme.md","/src","/examples","/assets","LICENSE"] +include = ["readme.md", "/src", "/examples", "/assets", "LICENSE"] [[bin]] name = "bevy_mod_scripting_doc_gen" @@ -21,15 +21,15 @@ name = "bevy_mod_scripting" path = "src/lib.rs" [package.metadata."docs.rs"] -features = ["lua","lua54","rhai","lua_script_api","rhai_script_api","teal"] +features = ["lua", "lua54", "rhai", "lua_script_api", "rhai_script_api", "teal"] [package.metadata.release] pre-release-replacements = [ - {file="Cargo.toml", search='^version\s*=\s*.*$', replace="version = \"{{version}}\"", exactly=1}, - {file="Cargo.toml", search='^(?Pbevy_mod_scripting_core\s*=.*)version\s*=\s*".*"(?P.*)$', replace="${h}version = \"{{version}}\"${t}", exactly=1}, - {file="Cargo.toml", search='^(?Pbevy_mod_scripting_lua\s*=.*)version\s*=\s*".*"(?P.*)$', replace="${h}version = \"{{version}}\"${t}", exactly=1}, - {file="Cargo.toml", search='^(?Pbevy_mod_scripting_rhai\s*=.*)version\s*=\s*".*"(?P.*)$', replace="${h}version = \"{{version}}\"${t}", exactly=1}, - {file="Cargo.toml", search='^(?Pbevy_script_api\s*=.*)version\s*=\s*".*"(?P.*)$', replace="${h}version = \"{{version}}\"${t}", exactly=1}, + { file = "Cargo.toml", search = '^version\s*=\s*.*$', replace = "version = \"{{version}}\"", exactly = 1 }, + { file = "Cargo.toml", search = '^(?Pbevy_mod_scripting_core\s*=.*)version\s*=\s*".*"(?P.*)$', replace = "${h}version = \"{{version}}\"${t}", exactly = 1 }, + { file = "Cargo.toml", search = '^(?Pbevy_mod_scripting_lua\s*=.*)version\s*=\s*".*"(?P.*)$', replace = "${h}version = \"{{version}}\"${t}", exactly = 1 }, + { file = "Cargo.toml", search = '^(?Pbevy_mod_scripting_rhai\s*=.*)version\s*=\s*".*"(?P.*)$', replace = "${h}version = \"{{version}}\"${t}", exactly = 1 }, + { file = "Cargo.toml", search = '^(?Pbevy_script_api\s*=.*)version\s*=\s*".*"(?P.*)$', replace = "${h}version = \"{{version}}\"${t}", exactly = 1 }, ] [features] @@ -47,8 +47,8 @@ luajit = ["bevy_mod_scripting_lua/luajit", "lua"] luajit52 = ["bevy_mod_scripting_lua/luajit52", "lua"] # optional -lua_script_api=["bevy_script_api/lua"] -unsafe_lua_modules=["bevy_mod_scripting_lua/unsafe_lua_modules"] +lua_script_api = ["bevy_script_api/lua"] +unsafe_lua_modules = ["bevy_mod_scripting_lua/unsafe_lua_modules"] teal = ["bevy_mod_scripting_lua/teal"] mlua_serialize = ["bevy_mod_scripting_lua/mlua_serialize"] mlua_macros = ["bevy_mod_scripting_lua/mlua_macros"] @@ -56,21 +56,21 @@ mlua_async = ["bevy_mod_scripting_lua/mlua_async"] ## rhai rhai = ["bevy_mod_scripting_rhai"] -rhai_script_api=["bevy_script_api/rhai"] +rhai_script_api = ["bevy_script_api/rhai"] [dependencies] -bevy = { version = "0.10.1", default-features = false} +bevy = { version = "0.10.1", default-features = false } bevy_mod_scripting_core = { path = "bevy_mod_scripting_core", version = "0.3.0" } bevy_mod_scripting_lua = { path = "languages/bevy_mod_scripting_lua", version = "0.3.0", optional = true } -bevy_mod_scripting_rhai = { path = "languages/bevy_mod_scripting_rhai", version = "0.3.0", optional = true} +bevy_mod_scripting_rhai = { path = "languages/bevy_mod_scripting_rhai", version = "0.3.0", optional = true } bevy_script_api = { path = "bevy_script_api", version = "0.3.0", optional = true } [dev-dependencies] -bevy = { version = "0.10.1"} -clap = { version = "4.1", features = ["derive"]} +bevy = { version = "0.10.1" } +clap = { version = "4.1", features = ["derive"] } rand = "0.8.5" bevy_console = "0.7.0" -rhai-rand = "0.1" +rhai-rand = "0.1" [workspace] resolver = "2" @@ -84,7 +84,7 @@ members = [ "languages/bevy_mod_scripting_lua_derive", "languages/bevy_mod_scripting_rhai", "languages/bevy_mod_scripting_rhai_derive", - "bevy_mod_scripting_common" + "bevy_mod_scripting_common", ] [profile.dev] @@ -97,60 +97,57 @@ opt-level = 3 [[example]] name = "console_integration_lua" path = "examples/lua/console_integration.rs" -required-features = ["lua54","lua_script_api"] +required-features = ["lua54", "lua_script_api"] [[example]] name = "console_integration_rhai" path = "examples/rhai/console_integration.rs" -required-features = ["rhai","rhai_script_api"] +required-features = ["rhai", "rhai_script_api"] [[example]] name = "complex_game_loop_lua" path = "examples/lua/complex_game_loop.rs" -required-features=["lua54"] +required-features = ["lua54"] [[example]] name = "game_of_life_lua" path = "examples/lua/game_of_life.rs" -required-features=["lua54","teal","lua_script_api"] +required-features = ["lua54", "teal", "lua_script_api"] [[example]] name = "game_of_life_rhai" path = "examples/rhai/game_of_life.rs" -required-features=["rhai","rhai_script_api"] +required-features = ["rhai", "rhai_script_api"] [[example]] name = "event_recipients_lua" path = "examples/lua/event_recipients.rs" -required-features=["lua54"] +required-features = ["lua54"] [[example]] name = "coroutines_lua" path = "examples/lua/coroutines.rs" -required-features=["lua54"] +required-features = ["lua54"] [[example]] name = "documentation_gen_lua" path = "examples/lua/documentation_gen.rs" -required-features=["lua54","teal","lua_script_api"] +required-features = ["lua54", "teal", "lua_script_api"] [[example]] name = "bevy_api_lua" path = "examples/lua/bevy_api.rs" -required-features=["lua54","lua_script_api"] +required-features = ["lua54", "lua_script_api"] [[example]] name = "bevy_api_rhai" path = "examples/rhai/bevy_api.rs" -required-features=["rhai","rhai_script_api"] +required-features = ["rhai", "rhai_script_api"] [[example]] name = "wrappers" -path = "examples/wrappers.rs" -required-features=["lua54","lua_script_api"] - - - +path = "examples/new_wrappers.rs" +required-features = ["lua54", "lua_script_api"] diff --git a/examples/wrappers.rs b/examples/new_wrappers.rs similarity index 100% rename from examples/wrappers.rs rename to examples/new_wrappers.rs From 780276c48fde9449c2664de183571c6dd34adeed Mon Sep 17 00:00:00 2001 From: makspll Date: Thu, 24 Aug 2023 09:02:56 +0100 Subject: [PATCH 20/94] fix merge issues --- Cargo.toml | 6 +++++- examples/new_wrappers.rs | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3b711fec28..749a5df6e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -146,8 +146,12 @@ name = "bevy_api_rhai" path = "examples/rhai/bevy_api.rs" required-features = ["rhai", "rhai_script_api"] - [[example]] name = "wrappers" +path = "examples/wrappers.rs" +required-features = ["lua54", "lua_script_api"] + +[[example]] +name = "new_wrappers" path = "examples/new_wrappers.rs" required-features = ["lua54", "lua_script_api"] diff --git a/examples/new_wrappers.rs b/examples/new_wrappers.rs index beb1db17dd..d641506448 100644 --- a/examples/new_wrappers.rs +++ b/examples/new_wrappers.rs @@ -57,12 +57,12 @@ fn main() -> std::io::Result<()> { let mut app = App::new(); app.add_plugins(DefaultPlugins) - .add_plugin(ScriptingPlugin) - .add_script_host_to_base_set::, _>(CoreSet::PostUpdate) + .add_plugins(ScriptingPlugin) + .add_script_host::>(PostUpdate) .register_type::() .init_resource::() .add_api_provider::>(Box::new(LuaBevyAPIProvider)) - .add_system(|world: &mut World| { + .add_systems(Startup, |world: &mut World| { world.insert_resource(MyProxiedStruct { my_string: "I was retrieved from the world".to_owned(), }); From e5bc2ba67fbefd55b54f2ff537874bf99eb08c29 Mon Sep 17 00:00:00 2001 From: makspll Date: Thu, 24 Aug 2023 18:08:36 +0100 Subject: [PATCH 21/94] fix issues with bevy 0.11 migration + minor changes --- bevy_script_api/src/wrappers.rs | 3 --- examples/new_wrappers.rs | 3 +-- .../bevy_mod_scripting_lua_derive/Cargo.toml | 26 +++++++++++-------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/bevy_script_api/src/wrappers.rs b/bevy_script_api/src/wrappers.rs index a6a37dd847..4bca3a4b34 100644 --- a/bevy_script_api/src/wrappers.rs +++ b/bevy_script_api/src/wrappers.rs @@ -4,9 +4,6 @@ use bevy::reflect::Reflect; pub trait ScriptValue: Reflect + Clone {} impl ScriptValue for T {} -/// Script representable type with pass-by-reference semantics -pub trait ScriptReference: Reflect {} -impl ScriptReference for T {} #[macro_export] macro_rules! ref_only_wrapper_methods { diff --git a/examples/new_wrappers.rs b/examples/new_wrappers.rs index d641506448..c6fc72fe68 100644 --- a/examples/new_wrappers.rs +++ b/examples/new_wrappers.rs @@ -18,7 +18,7 @@ impl Display for MyError { impl Error for MyError {} -#[derive(ScriptProxy, Reflect, Resource, Default, Debug)] +#[derive(ScriptProxy, Reflect, Resource, Default, Debug, Clone)] #[reflect(Resource, LuaProxyable)] #[proxy(languages("on_feature(lua)"), derive(Clone))] #[functions[ @@ -34,7 +34,6 @@ impl Error for MyError {} format!("{:#?}", _self) } ]] -#[derive(Clone)] pub struct MyProxiedStruct { my_string: String, } diff --git a/languages/bevy_mod_scripting_lua_derive/Cargo.toml b/languages/bevy_mod_scripting_lua_derive/Cargo.toml index d89e3e9e3c..71cf4cd370 100644 --- a/languages/bevy_mod_scripting_lua_derive/Cargo.toml +++ b/languages/bevy_mod_scripting_lua_derive/Cargo.toml @@ -13,33 +13,37 @@ readme = "readme.md" [package.metadata.release] pre-release-replacements = [ - {file="Cargo.toml", search='^version\s*=\s*.*$', replace="version = \"{{version}}\"", exactly=1}, - {file="Cargo.toml", search='^(?Pbevy_mod_scripting_common\s*=.*)version\s*=\s*".*"(?P.*)$', replace="${h}version = \"{{version}}\"${t}", exactly=1}, + { file = "Cargo.toml", search = '^version\s*=\s*.*$', replace = "version = \"{{version}}\"", exactly = 1 }, + { file = "Cargo.toml", search = '^(?Pbevy_mod_scripting_common\s*=.*)version\s*=\s*".*"(?P.*)$', replace = "${h}version = \"{{version}}\"${t}", exactly = 1 }, ] [lib] -name="bevy_mod_scripting_lua_derive" -path="src/lib.rs" -proc-macro=true +name = "bevy_mod_scripting_lua_derive" +path = "src/lib.rs" +proc-macro = true [dependencies] -bevy_mod_scripting_common = {path = "../../bevy_mod_scripting_common", version = "0.3.0" } +bevy_mod_scripting_common = { path = "../../bevy_mod_scripting_common", version = "0.3.0" } paste = "1.0.7" -syn = {version="1.0.57",features=["full","fold","extra-traits"]} +syn = { version = "1.0.57", features = ["full", "fold", "extra-traits"] } quote = "1.0.8" proc-macro2 = "1.0" convert_case = "0.5.0" rustdoc-types = "0.11.0" serde = { version = "1.0", features = ["derive"] } serde_derive = "1.0.137" -indexmap = {version= "1.9.1", features= ["serde"]} +indexmap = { version = "1.9.1", features = ["serde"] } proc-macro-error = "1" strum = { version = "0.24.1", features = ["derive"] } [dev-dependencies] trybuild = "1.0" -bevy = { version = "0.10.1", default-features = false} -bevy_mod_scripting = { path = "../../../bevy_mod_scripting", version = "0.3.0", features=["lua", "lua_script_api", "lua54"] } +bevy = { version = "0.11", default-features = false } +bevy_mod_scripting = { path = "../../../bevy_mod_scripting", version = "0.3.0", features = [ + "lua", + "lua_script_api", + "lua54", +] } bevy_script_api = { path = "../../bevy_script_api", version = "0.3.0" } bevy_mod_scripting_lua = { path = "../bevy_mod_scripting_lua", version = "0.3.0" } -bevy_mod_scripting_core = { path = "../../bevy_mod_scripting_core", version = "0.3.0" } \ No newline at end of file +bevy_mod_scripting_core = { path = "../../bevy_mod_scripting_core", version = "0.3.0" } From 6a2cf63dd29ac94bb3d9474f60c56e2441bd7163 Mon Sep 17 00:00:00 2001 From: makspll Date: Fri, 25 Aug 2023 12:30:51 +0100 Subject: [PATCH 22/94] fix test errors --- languages/bevy_mod_scripting_lua_derive/src/lib.rs | 5 +++-- .../tests/fail/references/non-proxy-reference.stderr | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/languages/bevy_mod_scripting_lua_derive/src/lib.rs index a94f0f2298..3ee4c54e38 100644 --- a/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -700,7 +700,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { #tealr_type_implementations #[automatically_derived] - #[allow(unused_parens,unused_braces,unused_mut)] + #[allow(unused_parens, unused_braces, unused_mut, unused_variables)] #[allow(clippy::all)] impl #tealr::mlu::TealData for #proxy_type { fn add_methods<'lua, T: #tealr::mlu::TealDataMethods<'lua, Self>>(methods: &mut T) { @@ -713,7 +713,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { } } - #[allow(clippy::all)] + #[allow(clippy::all, unused_variables)] impl bevy_script_api::lua::LuaProxyable for #proxied_name { fn ref_to_lua<'lua>(self_ : bevy_script_api::script_ref::ScriptRef, lua: &'lua #tealr::mlu::mlua::Lua) -> #tealr::mlu::mlua::Result<#tealr::mlu::mlua::Value<'lua>> { <#proxy_type as #tealr::mlu::mlua::ToLua>::to_lua(#proxy_type::new_ref(self_),lua) @@ -734,6 +734,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { } } + #[allow(clippy::all, unused_variables)] impl bevy_script_api::lua::ToLuaProxy<'_> for #proxied_name { fn to_lua_proxy<'lua>(self, lua: &'lua #tealr::mlu::mlua::Lua) -> #tealr::mlu::mlua::Result<#tealr::mlu::mlua::Value<'lua>>{ <#proxy_type as #tealr::mlu::mlua::ToLua>::to_lua(#proxy_type::new(self),lua) diff --git a/languages/bevy_mod_scripting_lua_derive/tests/fail/references/non-proxy-reference.stderr b/languages/bevy_mod_scripting_lua_derive/tests/fail/references/non-proxy-reference.stderr index 57e898817a..b5ac5b54aa 100644 --- a/languages/bevy_mod_scripting_lua_derive/tests/fail/references/non-proxy-reference.stderr +++ b/languages/bevy_mod_scripting_lua_derive/tests/fail/references/non-proxy-reference.stderr @@ -19,5 +19,8 @@ error[E0277]: the trait bound `&str: LuaUserData` is not satisfied note: required by a bound in `bevy_mod_scripting_lua::tealr::mlu::TealDataMethods::add_function` --> $CARGO/tealr-0.9.0-alpha4/src/mlu/teal_data_methods.rs | + | fn add_function(&mut self, name: &S, function: F) + | ------------ required by a bound in this associated function +... | A: FromLuaMulti<'lua> + TealMultiValue, | ^^^^^^^^^^^^^^^^^^ required by this bound in `TealDataMethods::add_function` From 09796b41f912f542153df716edce5e55d5feb175 Mon Sep 17 00:00:00 2001 From: makspll Date: Fri, 25 Aug 2023 12:35:09 +0100 Subject: [PATCH 23/94] silence deprecated macro warnings --- examples/lua/game_of_life.rs | 1 + examples/new_wrappers.rs | 8 ++------ examples/wrappers.rs | 2 ++ 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/lua/game_of_life.rs b/examples/lua/game_of_life.rs index 5bee2236d2..52cb2dd1d0 100644 --- a/examples/lua/game_of_life.rs +++ b/examples/lua/game_of_life.rs @@ -1,3 +1,4 @@ +#![allow(deprecated)] use std::{borrow::Cow, sync::Mutex, time::Duration}; use bevy::{ diff --git a/examples/new_wrappers.rs b/examples/new_wrappers.rs index c6fc72fe68..07a3f9bd86 100644 --- a/examples/new_wrappers.rs +++ b/examples/new_wrappers.rs @@ -1,17 +1,13 @@ use bevy::{app::AppExit, prelude::*}; -use bevy_mod_scripting::{ - api::{impl_lua_newtype, impl_script_newtype, lua::bevy::LuaWorld, ScriptProxy, ScriptRef}, - prelude::*, -}; +use bevy_mod_scripting::{api::ScriptProxy, prelude::*}; -use mlua::Error as LuaError; use std::error::Error; use std::fmt::Display; #[derive(Debug)] pub struct MyError; impl Display for MyError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { todo!() } } diff --git a/examples/wrappers.rs b/examples/wrappers.rs index fe10026255..d8fc2bd34b 100644 --- a/examples/wrappers.rs +++ b/examples/wrappers.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use bevy::{app::AppExit, prelude::*}; use bevy_mod_scripting::{ From f5a067aeef6e46e6987ca5b685ccbf6ddd9bfa68 Mon Sep 17 00:00:00 2001 From: makspll Date: Thu, 31 Aug 2023 14:54:57 +0100 Subject: [PATCH 24/94] WIP fields --- bevy_mod_scripting_common/src/input.rs | 1 + .../bevy_mod_scripting_lua_derive/src/lib.rs | 202 +++++++++++++----- 2 files changed, 152 insertions(+), 51 deletions(-) diff --git a/bevy_mod_scripting_common/src/input.rs b/bevy_mod_scripting_common/src/input.rs index 0ffd756673..70219cd0cc 100644 --- a/bevy_mod_scripting_common/src/input.rs +++ b/bevy_mod_scripting_common/src/input.rs @@ -611,6 +611,7 @@ impl TryFrom for ProxyMeta { let docstrings = derive_input .attrs .iter() + .filter(|attr| attr.path.is_ident("doc")) .map(attribute_to_string_lit) .filter(|s| !s.is_empty()) .collect(); diff --git a/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/languages/bevy_mod_scripting_lua_derive/src/lib.rs index 3ee4c54e38..6ff62d1f7e 100644 --- a/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -12,7 +12,7 @@ use proc_macro2::*; use proc_macro_error::*; use quote::*; use strum::*; -use syn::{*, spanned::*, token::{Mut, Paren}, punctuated::Punctuated, visit_mut::VisitMut}; +use syn::{*, spanned::*, token::{Mut, Paren, Bracket}, punctuated::Punctuated, visit_mut::VisitMut}; use visitor::{LuaSimpleTypeArgumentUnwrapper, LuaTypeConstructorVisitor}; use crate::visitor::LuaSimpleTypeWrapper; @@ -39,6 +39,35 @@ const SELF_ALIAS: &str = "_self"; const PROXIED_OUT_ALIAS: &str = "__proxied_out"; const PROXY_OUT_ALIAS: &str = "__proxy_out"; const PROXY_PREFIX: &str = "Lua"; +const VALID_META_METHODS : [&str; 27] = [ + "Add", + "Sub", + "Mul", + "Div", + "Mod", + "Pow", + "Unm", + "IDiv", + "BAnd", + "BOr", + "BXor", + "BNot", + "Shl", + "Shr", + "Concat", + "Len", + "Eq", + "Lt", + "Le", + "Index", + "NewIndex", + "Call", + "ToString", + "Pairs", + "IPairs", + "Iter", + "Close", +]; #[derive(Debug)] struct FunctionArgMeta { @@ -250,7 +279,6 @@ impl FunctionMeta<'_> { &output_type, output_attrs, ) - , }; // validate the function against it's meta @@ -288,8 +316,9 @@ impl FunctionMeta<'_> { self_arg = Some(quote_spanned!(meta.span=> , #self_name : & #_mut #self_type)); } } - - let (args, arg_types) = args + + if self.fn_type.expects_arguments_other_than_self() { + let (args, arg_types) = args .map(|fn_arg| { let _mut = &fn_arg.mutable; let name = &fn_arg.arg_name; @@ -303,7 +332,11 @@ impl FunctionMeta<'_> { }) .unzip::<_, _, Vec, Vec>(); - quote_spanned!(self.body.sig.inputs.span()=>_ #self_arg , (#(#args),*) : (#(#arg_types),*)) + quote_spanned!(self.body.sig.inputs.span()=>_ #self_arg , (#(#args),*) : (#(#arg_types),*)) + } else { + quote_spanned!(self.body.sig.inputs.span()=>_ #self_arg) + } + } /// Takes all the argument identifiers passed into the function, generates assignments which shadow the original @@ -418,8 +451,6 @@ impl FunctionMeta<'_> { } fn generate_mlua_body(&self, proxied_name: &Ident) -> proc_macro2::TokenStream { - - let unpacked_parameter_declarations = self.generate_mlua_body_unwrapped_parameter_assignments(); let proxied_output_ident = format_ident!("{PROXIED_OUT_ALIAS}", span=self.output_meta.span); @@ -431,7 +462,7 @@ impl FunctionMeta<'_> { // determine if we need to wrap the output in an Ok() statement let last_stm = match &self.output_meta.arg_type { SimpleType::DuoPath(DuoPath{ ident , ..}) if *ident == "Result" => quote_spanned! {self.body.span()=>#proxy_output_ident}, - _ => quote_spanned! {self.body.span()=>Ok(#proxy_output_ident)} + _ => quote_spanned! {self.body.span()=>Ok(#proxy_output_ident)}, }; let conversion_body_stms = quote!( @@ -465,12 +496,10 @@ impl FunctionMeta<'_> { } ); - quote!( #unpacked_parameter_declarations #conversion_body_surrounded_with_dereferening_stms ) - } @@ -528,6 +557,8 @@ enum FunctionType { MutableMetaFunction, MutatingMethod, MutatingMetaMethod, + FieldGetterMethod, + FieldSetterMethod, } impl FunctionType { @@ -536,10 +567,22 @@ impl FunctionType { || self == FunctionType::MetaMethod || self == FunctionType::MutatingMethod || self == FunctionType::MutatingMetaMethod + || self == FunctionType::FieldGetterMethod + || self == FunctionType::FieldSetterMethod } fn expects_mutable_receiver(self) -> bool { - self == FunctionType::MutatingMethod || self == FunctionType::MutatingMetaMethod + self == FunctionType::MutatingMethod + || self == FunctionType::FieldSetterMethod + } + + fn is_field(self) -> bool { + self == FunctionType::FieldGetterMethod || + self == FunctionType::FieldSetterMethod + } + + fn expects_arguments_other_than_self(self) -> bool { + self != FunctionType::FieldGetterMethod } fn get_tealr_function(self) -> &'static str { @@ -552,6 +595,8 @@ impl FunctionType { FunctionType::MutableMetaFunction => "add_meta_function_mut", FunctionType::MutatingMethod => "add_method_mut", FunctionType::MutatingMetaMethod => "add_meta_method_mut", + FunctionType::FieldGetterMethod => "add_field_method_get", + FunctionType::FieldSetterMethod => "add_field_method_set", } } @@ -621,8 +666,81 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { .map(|tkns| quote_spanned!(meta.span=>methods.document_type(#tkns);)); let tealr = quote!(bevy_mod_scripting_lua::tealr); - // generate both tealr documentation and instantiations of functions - let methods = meta.functions.iter().map(|(name, body)| { + let field_methods : Vec<(Ident, TraitItemMethod)> = match meta.data { + ProxyData::Struct { fields } => { + let field_processor = |idx: usize, field: &Field, is_setter: bool| { + let field_name = field.ident.clone().unwrap_or_else(|| format_ident!("{}", idx)); + let field_type = &field.ty; + let docs = field.attrs.iter() + .filter(|attr| attr.path.is_ident("doc")) + .collect::>(); + + let mut lua_attr = field.attrs.iter() + .find(|attr| attr.path.is_ident("proxy")) + .map(|attr| attr.parse_meta().unwrap_or_abort()) + .and_then(|meta| match meta { + Meta::List(MetaList { nested, .. }) => nested.iter().find_map(|attr| match attr { + NestedMeta::Meta(l@Meta::List(MetaList { nested , .. })) + if l.path().is_ident("lua") => Some(nested.clone()), + _ => None + } ), + _ => None + }) + .unwrap_or_else(Punctuated::::new); + + + if is_setter { + lua_attr.extend::>(parse_quote!(lua(FieldSetterMethod))); + } else { + lua_attr.extend::>(parse_quote!(lua(FieldGetterMethod))); + } + + + let lua_attr = Attribute { + pound_token: Token![#](fields.span()), + style: AttrStyle::Outer, + bracket_token: Bracket::default(), + path: Path{ leading_colon: None, segments: Default::default() }, + tokens: lua_attr.to_token_stream() + }; + + let trait_item_method : TraitItemMethod = if is_setter { + parse_quote!{ + #lua_attr + #(#docs)* + fn #field_name (&mut self, other: #field_type) { + self.#field_name; + () + } + } + } else { + parse_quote!{ + #lua_attr + #(#docs)* + fn #field_name (&self) -> #field_type { + self.#field_name + } + } + }; + + (field_name, trait_item_method) + }; + + let mut out = fields.iter().enumerate().map(|(idx,field)| + field_processor(idx,field,false)).collect::>(); + + out.extend(fields.iter().enumerate().map(|(idx,field)| + field_processor(idx,field,true)).collect::>()); + out + }, + }; + + + // generate both tealr documentation and instantiations of functions and field getters/setters + let (fields, methods) = meta.functions.iter() + // treat field getters and setters as normal methods for the time being, separate later + .chain(field_methods.iter().map(|(a,b)| (a,b))) + .map(|(name, body)| { let method_documentation_calls = body .attrs .iter() @@ -646,38 +764,9 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { .is_meta() .then(|| { let name = fn_meta.name; - let valid_meta_methods : HashSet<&'static str> = HashSet::from_iter([ - "Add", - "Sub", - "Mul", - "Div", - "Mod", - "Pow", - "Unm", - "IDiv", - "BAnd", - "BOr", - "BXor", - "BNot", - "Shl", - "Shr", - "Concat", - "Len", - "Eq", - "Lt", - "Le", - "Index", - "NewIndex", - "Call", - "ToString", - "Pairs", - "IPairs", - "Iter", - "Close", - ].into_iter()); // check is valid meta method if not use custom name - if valid_meta_methods.contains(name.to_string().as_str()) { + if VALID_META_METHODS.contains(&name.to_string().as_str()) { quote!(#tealr::mlu::mlua::MetaMethod::#name) } else { let std_string = name.to_string(); @@ -686,14 +775,23 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { }) .unwrap_or_else(|| fn_meta.name.to_string().to_token_stream()); - quote_spanned! {body.span()=> - #(#method_documentation_calls)* - methods.#tealr_function(#signature, #closure); - } - }); + let container_ident = if fn_meta.fn_type.is_field() { + format_ident!("fields", span=body.span()) + } else { + format_ident!("methods", span=body.span()) + }; + (fn_meta.fn_type.is_field(), + quote_spanned! {body.span()=> + #(#method_documentation_calls)* + #container_ident.#tealr_function(#signature, #closure); + } + ) + }).partition::,_>(|(is_field,_)| *is_field); - quote_spanned! {meta.span=> + let fields = fields.iter().map(|(_, b)| b); + let methods = methods.iter().map(|(_, b)| b); + let a = quote_spanned! {meta.span=> #definition @@ -709,7 +807,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { } fn add_fields<'lua, T: #tealr::mlu::TealDataFields<'lua, Self>>(fields: &mut T) { - + #(#fields)* } } @@ -742,5 +840,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { } } - .into() + .into(); + // panic!("{}", a); + a } \ No newline at end of file From 67cc8a9d563eaec6f187d3ceb1e6037d818a25d9 Mon Sep 17 00:00:00 2001 From: makspll Date: Mon, 9 Oct 2023 17:54:41 +0100 Subject: [PATCH 25/94] WIP --- bevy_mod_scripting_common/src/input.rs | 16 +- examples/new_wrappers.rs | 38 +++-- .../bevy_mod_scripting_lua_derive/src/lib.rs | 147 ++++++++++++------ .../src/visitor.rs | 5 +- 4 files changed, 135 insertions(+), 71 deletions(-) diff --git a/bevy_mod_scripting_common/src/input.rs b/bevy_mod_scripting_common/src/input.rs index 70219cd0cc..95b75396ea 100644 --- a/bevy_mod_scripting_common/src/input.rs +++ b/bevy_mod_scripting_common/src/input.rs @@ -515,12 +515,9 @@ impl VisitSimpleType for TypeConstructorVisitor { arguments: PathArguments::AngleBracketed(AngleBracketedGenericArguments { colon2_token: unit_path.colon2_token, lt_token: unit_path.lt_token, - args: Punctuated::from_iter( - [GenericArgument::Type( - self.visit_simple_type(&unit_path.inner, false), - )] - .into_iter(), - ), + args: Punctuated::from_iter([GenericArgument::Type( + self.visit_simple_type(&unit_path.inner, false), + )]), gt_token: unit_path.gt_token, }), } @@ -539,9 +536,10 @@ impl VisitSimpleType for TypeConstructorVisitor { arguments: PathArguments::AngleBracketed(AngleBracketedGenericArguments { colon2_token: duo_path.colon2_token, lt_token: duo_path.lt_token, - args: Punctuated::from_iter( - [GenericArgument::Type(left), GenericArgument::Type(right)].into_iter(), - ), + args: Punctuated::from_iter([ + GenericArgument::Type(left), + GenericArgument::Type(right), + ]), gt_token: duo_path.gt_token, }), } diff --git a/examples/new_wrappers.rs b/examples/new_wrappers.rs index 07a3f9bd86..4b335bbfe8 100644 --- a/examples/new_wrappers.rs +++ b/examples/new_wrappers.rs @@ -18,17 +18,24 @@ impl Error for MyError {} #[reflect(Resource, LuaProxyable)] #[proxy(languages("on_feature(lua)"), derive(Clone))] #[functions[ - #[lua(MutatingMethod)] - fn set_my_string(&mut self, another_string: Option); + // #[lua(MutatingMethod)] + // fn set_my_string(&mut self, another_string: Option); - #[lua(Method)] - fn get_my_string(&self) -> String; + // #[lua(Method)] + // fn get_my_string(&self) -> String; - - #[lua(MetaMethod)] - fn ToString(&self) -> String { - format!("{:#?}", _self) + #[lua(Method,raw)] + fn raw_method(&self, ctx : &Lua) -> Result { + let a = ctx.globals().get::<_,String>("world").unwrap(); + let a = self.inner()?; + Ok("".to_owned()) } + + + // #[lua(MetaMethod)] + // fn ToString(&self) -> String { + // format!("{:#?}", _self) + // } ]] pub struct MyProxiedStruct { my_string: String, @@ -36,15 +43,16 @@ pub struct MyProxiedStruct { impl MyProxiedStruct { fn set_my_string(&mut self, another_string: Option) { - if let Some(s) = another_string { - self.my_string = s; - } else { - self.my_string = "".to_owned(); - } + // if let Some(s) = another_string { + // self.my_string = s; + // } else { + // self.my_string = "".to_owned(); + // } } fn get_my_string(&self) -> String { - self.my_string.clone() + // self.my_string.clone() + "".to_owned() } } @@ -59,7 +67,7 @@ fn main() -> std::io::Result<()> { .add_api_provider::>(Box::new(LuaBevyAPIProvider)) .add_systems(Startup, |world: &mut World| { world.insert_resource(MyProxiedStruct { - my_string: "I was retrieved from the world".to_owned(), + // my_string: "I was retrieved from the world".to_owned(), }); // run script diff --git a/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/languages/bevy_mod_scripting_lua_derive/src/lib.rs index 6ff62d1f7e..9f16939a64 100644 --- a/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -77,29 +77,34 @@ struct FunctionArgMeta { span: Span, /// variant specific data enumeration arg_type: SimpleType, + /// if an argument is raw, it's passed without any unwrapping to the handler function + /// if an argument isn't annotated with the `proxy` flag it is technically raw, but this is different for receiver and output arguments + is_raw: bool, + } impl FunctionArgMeta { /// Creates a new meta structure corresponding to the given function argument. /// Resolves receivers with the given proxy name. /// Uses given span if available, otherwise uses the span of the function argument - fn new_from_fn_arg(proxied_type_identifier: &Ident, fn_arg: &FnArg, span: Option) -> Self { + fn new_from_fn_arg(proxied_type_identifier: &Ident, fn_arg: &FnArg, span: Option, in_raw_function: bool) -> Self { let arg_name; let mutable; let arg_type; let span = span.unwrap_or(fn_arg.span()); let proxied_type_identifier = &mut proxied_type_identifier.clone(); proxied_type_identifier.set_span(span); + let is_raw = in_raw_function; // the proxied type is always proxied with the `Lua` prefix let mut proxy_ident_map = HashMap::from_iter( - [(proxied_type_identifier.clone(),None)].into_iter() + [(proxied_type_identifier.clone(),None)] ); match fn_arg { FnArg::Receiver(receiver) => { arg_type = SimpleType::new_from_fn_arg(PROXY_PREFIX, fn_arg, proxied_type_identifier, &proxy_ident_map).unwrap_or_abort(); - + // normally receivers are assumed to be wrapped, this let's us opt out of this behaviour if let Some(_mut) = receiver.mutability { mutable = Some(_mut) } else { @@ -123,12 +128,12 @@ impl FunctionArgMeta { // #[proxy(TypeName1=ProxyType1, TypeName2=ProxyType2, ..)] Meta::List(MetaList { nested, .. }) => { // collect all the types passed in the meta as identifiers - let idents = nested.iter().map(|nested_meta| { + let idents = nested.iter().filter_map(|nested_meta| { match nested_meta { NestedMeta::Meta(Meta::Path(path)) => - (path.get_ident().unwrap_or_else(|| abort!(path,"Expected identifier")).clone(),None), + Some((path.get_ident().unwrap_or_else(|| abort!(path,"Expected identifier")).clone(),None)), NestedMeta::Meta(Meta::NameValue(MetaNameValue{path, lit: Lit::Str(lit_str), ..})) => - (path.get_ident().unwrap_or_else(|| abort!(path,"Expected identifier")).clone(), Some(lit_str.parse().unwrap_or_abort())), + Some((path.get_ident().unwrap_or_else(|| abort!(path,"Expected identifier")).clone(), Some(lit_str.parse().unwrap_or_abort()))), _ => abort!(nested_meta.span(), "Expected proxy identifier mapping as in: `proxy(TypeName=ProxyType)` or `proxy(TypeName)` for `LuaTypeName`"), } }).collect::)>>(); @@ -157,6 +162,7 @@ impl FunctionArgMeta { arg_name, span, arg_type, + is_raw } } @@ -166,6 +172,7 @@ impl FunctionArgMeta { arg_name: Ident, arg_type: &Type, attrs: Vec, + in_raw_function: bool, ) -> Self { let ty = Box::new(arg_type.clone()); let pat_ty = PatType { @@ -182,15 +189,21 @@ impl FunctionArgMeta { }; let fn_arg = FnArg::Typed(pat_ty); - Self::new_from_fn_arg(proxied_type_identifier, &fn_arg, Some(arg_type.span())) + Self::new_from_fn_arg(proxied_type_identifier, &fn_arg, Some(arg_type.span()), in_raw_function) } /// Unpacks non-reference proxy parameters (using the `inner` method) yielding expressions which correspond to the proxied type with conversion errors being /// handled by the try `?` operator. - pub fn unpack_parameter(&self) -> proc_macro2::TokenStream { + pub fn unpack_parameter(&self) -> Option { let name = &self.arg_name; - // if a proxy parameter is to be passed by value we use inner (which requires Clone to be supported) - LuaSimpleTypeArgumentUnwrapper::new(name.clone(), name.span()).visit(&self.arg_type) + if self.is_raw { + // raw parameters DO NOT get unpacked, they get passed directly to the handling method as is + None + } else { + // if a proxy parameter is to be passed by value we use inner (which requires Clone to be supported) + Some(LuaSimpleTypeArgumentUnwrapper::new(name.clone(), name.span()).visit(&self.arg_type)) + } + } @@ -203,6 +216,7 @@ struct FunctionMeta<'a> { fn_type: FunctionType, arg_meta: Vec, output_meta: FunctionArgMeta, + is_raw: bool, } impl FunctionMeta<'_> { @@ -231,27 +245,35 @@ impl FunctionMeta<'_> { match meta { Meta::List(MetaList { nested, .. }) => { let mut fn_type = FunctionType::Function; - + let mut is_raw = false; nested .iter() .for_each(|attr|{ - if let NestedMeta::Meta(Meta::Path(p)) = attr { - let attr_str = p.get_ident().map(Ident::to_string).unwrap_or_default(); - if let Ok(_fn_type) = FunctionType::from_str(&attr_str) { - fn_type = _fn_type; + match attr { + NestedMeta::Meta(Meta::Path(p)) if p.is_ident("raw") => { + is_raw = true; return; - } else { - abort!(p, "Invalid Function Type, expected one of: {}", - FunctionType::iter().map(|ft| ft.to_string()).collect::>().join(", ")) - } - } else if let NestedMeta::Meta(Meta::List(list)) = attr { - if list.path.is_ident("output") { - for attr in list.nested.iter() { - output_attrs.push(parse_quote!(#[#attr])) + }, + NestedMeta::Meta(Meta::Path(p)) => { + let attr_str = p.get_ident().map(Ident::to_string).unwrap_or_default(); + if let Ok(_fn_type) = FunctionType::from_str(&attr_str) { + fn_type = _fn_type; + return; + } else { + abort!(p, "Invalid Function Type, expected one of: {}", + FunctionType::iter().map(|ft| ft.to_string()).collect::>().join(", ")) } - return; - } - } + }, + NestedMeta::Meta(Meta::List(list)) => { + if list.path.is_ident("output") { + for attr in list.nested.iter() { + output_attrs.push(parse_quote!(#[#attr])) + } + return; + } + }, + _ => return + }; emit_error!(attr, "unknown or malformed lua proxy function attribute. Allowed attributes include: {}", FunctionType::iter().map(|ft| ft.to_string()).collect::>().join(", ")); @@ -271,14 +293,16 @@ impl FunctionMeta<'_> { .sig .inputs .iter() - .map(|arg| FunctionArgMeta::new_from_fn_arg(&proxied_type_identifier, arg, None)) + .map(|arg| FunctionArgMeta::new_from_fn_arg(&proxied_type_identifier, arg, None, is_raw)) .collect(), output_meta: FunctionArgMeta::new_from_type( &proxied_type_identifier, format_ident!("{PROXIED_OUT_ALIAS}", span=body.sig.output.span()), &output_type, output_attrs, - ) + is_raw + ), + is_raw }; // validate the function against it's meta @@ -316,6 +340,15 @@ impl FunctionMeta<'_> { self_arg = Some(quote_spanned!(meta.span=> , #self_name : & #_mut #self_type)); } } + + let ctxt_arg = + if self.is_raw { + let meta = args.next().expect_or_abort("Expected `Lua` type argument before non-receiver arguments and after the receiver if any."); + let name = &meta.arg_name; + quote_spanned!(self.name.span()=>#name : &bevy_mod_scripting_lua::tealr::mlu::mlua::Lua) + } else { + quote_spanned!(self.name.span()=>_) + }; if self.fn_type.expects_arguments_other_than_self() { let (args, arg_types) = args @@ -332,9 +365,9 @@ impl FunctionMeta<'_> { }) .unzip::<_, _, Vec, Vec>(); - quote_spanned!(self.body.sig.inputs.span()=>_ #self_arg , (#(#args),*) : (#(#arg_types),*)) + quote_spanned!(self.body.sig.inputs.span()=>#ctxt_arg #self_arg , (#(#args),*) : (#(#arg_types),*)) } else { - quote_spanned!(self.body.sig.inputs.span()=>_ #self_arg) + quote_spanned!(self.body.sig.inputs.span()=>#ctxt_arg #self_arg) } } @@ -352,18 +385,13 @@ impl FunctionMeta<'_> { /// let other : MyType = other_ref.inner(); /// ``` fn generate_mlua_body_unwrapped_parameter_assignments(&self) -> proc_macro2::TokenStream { - let param_names = self.arg_meta + self.arg_meta .iter() - .map(|arg| &arg.arg_name); - - let unpacked_parameters = self.arg_meta - .iter() - .map(FunctionArgMeta::unpack_parameter) - .collect::>(); - - quote_spanned!{self.body.span()=> - #(let mut #param_names = #unpacked_parameters;)* - } + .filter_map(|param| FunctionArgMeta::unpack_parameter(param).map(|unpacked_param| { + let name = ¶m.arg_name; + quote_spanned!{name.span()=>let #name = #unpacked_param;} + })) + .collect::() } @@ -436,6 +464,12 @@ impl FunctionMeta<'_> { /// let __proxy_out : LuaMyType = LuaMyType::new(__proxied_out); /// ``` fn generate_mlua_body_proxy_output_stmt(&self, proxied_output_ident: &Ident, proxy_output_ident: &Ident) -> proc_macro2::TokenStream { + if self.output_meta.is_raw { + return quote_spanned! {self.body.span()=> + let #proxy_output_ident = #proxied_output_ident; + } + } + // generate `new` calls as required to build proxy stored in out_ident let constructor_wrapped_expression = LuaSimpleTypeWrapper::new(proxied_output_ident.clone(), proxied_output_ident.span()) @@ -481,6 +515,10 @@ impl FunctionMeta<'_> { if matches!(inner.as_ref(), SimpleType::ProxyType(_))){ return acc; } + // raw arguments are passed directly to the handler function + if arg_meta.is_raw { + return acc; + } let method_call = if arg_meta.arg_type.has_outer_mut_ref() { format_ident!("val_mut", span=arg_meta.span) @@ -514,6 +552,24 @@ impl FunctionMeta<'_> { ) } + if self.is_raw { + let ctxt_arg_idx = if self.fn_type.expects_receiver() {1} else {0}; + + let ctxt_arg = definition.sig.inputs.iter().nth(ctxt_arg_idx) + .ok_or_else(|| syn::Error::new_spanned(&definition.sig.inputs, + "Raw Lua proxy functions require a `&Lua` context argument following any receivers and before other arguments.")) + .unwrap_or_abort(); + + let success = match ctxt_arg { + FnArg::Typed(PatType{ ty, .. }) => matches!(ty.as_ref(), &Type::Reference(_)), + _ => false + }; + + if !success { + emit_error!(ctxt_arg, "Raw Lua proxy functions require a `&Lua` reference after any receivers and before other arguments.") + } + } + if self.fn_type.expects_receiver() { if let Some(FnArg::Receiver(receiver)) = definition.sig.receiver() { // validate receiver @@ -669,7 +725,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { let field_methods : Vec<(Ident, TraitItemMethod)> = match meta.data { ProxyData::Struct { fields } => { let field_processor = |idx: usize, field: &Field, is_setter: bool| { - let field_name = field.ident.clone().unwrap_or_else(|| format_ident!("{}", idx)); + let field_name = field.ident.clone().unwrap_or_else(|| format_ident!("_{}", idx)); let field_type = &field.ty; let docs = field.attrs.iter() .filter(|attr| attr.path.is_ident("doc")) @@ -694,6 +750,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { } else { lua_attr.extend::>(parse_quote!(lua(FieldGetterMethod))); } + lua_attr.extend::>(parse_quote!(raw)); let lua_attr = Attribute { @@ -708,7 +765,9 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { parse_quote!{ #lua_attr #(#docs)* - fn #field_name (&mut self, other: #field_type) { + fn #field_name (&mut self, lua: &Lua, other: #field_type) { + let world_ptr = ::get_world(lua)?; + self.#field_name; () } @@ -717,7 +776,7 @@ pub fn impl_lua_proxy(input: TokenStream) -> TokenStream { parse_quote!{ #lua_attr #(#docs)* - fn #field_name (&self) -> #field_type { + fn #field_name (&self, lua: &Lua) -> #field_type { self.#field_name } } diff --git a/languages/bevy_mod_scripting_lua_derive/src/visitor.rs b/languages/bevy_mod_scripting_lua_derive/src/visitor.rs index 4ffb569610..01c563a441 100644 --- a/languages/bevy_mod_scripting_lua_derive/src/visitor.rs +++ b/languages/bevy_mod_scripting_lua_derive/src/visitor.rs @@ -6,10 +6,9 @@ use quote::*; use syn::*; /// Generates an unwrapping expression which can be used to assign the unwrapped proxy to a variable. -/// for example for the type `MyType` with `__proxied_out` identifier -/// the argument `#[proxy] MyType` will generate the following expression: +/// the argument `#[proxy] arg: MyType` will generate the following expression: /// ```rust,ignore -/// let __proxied_out : MyType = other.inner()?; +/// arg.inner()?; /// ``` pub(crate) struct LuaSimpleTypeArgumentUnwrapper { arg_name: Ident, From 48eeaafe208d7f17ffab32d8dd864b822de9b611 Mon Sep 17 00:00:00 2001 From: makspll Date: Mon, 6 Nov 2023 15:35:51 +0000 Subject: [PATCH 26/94] WIP dump, sailfish integration, new codegen --- .vscode/launch.json | 27 +- .vscode/settings.json | 3 + .vscode/tasks.json | 29 + Cargo.toml | 3 +- bevy_api_gen/Cargo.toml | 21 +- bevy_api_gen/src/arg_validator.rs | 90 +- bevy_api_gen/src/config.rs | 22 +- bevy_api_gen/src/cratepath.rs | 60 +- bevy_api_gen/src/main.rs | 707 +- bevy_api_gen/src/wrapper.rs | 706 +- bevy_mod_scripting_common/Cargo.toml | 12 +- bevy_mod_scripting_common/src/arg.rs | 262 - bevy_mod_scripting_common/src/derive_data.rs | 251 - bevy_mod_scripting_common/src/derive_flag.rs | 202 - bevy_mod_scripting_common/src/implementor.rs | 75 - bevy_mod_scripting_common/src/input.rs | 416 +- bevy_mod_scripting_common/src/lib.rs | 6 - bevy_mod_scripting_common/src/newtype.rs | 177 - bevy_mod_scripting_common/src/ops.rs | 160 - bevy_mod_scripting_common/src/utils.rs | 8 +- bevy_mod_scripting_derive/src/lib.rs | 159 +- bevy_script_api/src/generated.rs | 98268 ++++++++++++++-- bevy_script_api/src/lib.rs | 6 +- bevy_script_api/src/wrappers.rs | 9 +- examples/new_wrappers.rs | 16 +- .../bevy_mod_scripting_lua_derive/Cargo.toml | 4 +- .../src/derive_flags/auto_methods.rs | 134 - .../src/derive_flags/bin_ops.rs | 217 - .../src/derive_flags/fields.rs | 101 - .../src/derive_flags/mod.rs | 6 - .../src/derive_flags/unary_ops.rs | 44 - .../src/implementor.rs | 259 - .../src/impls.rs | 165 - .../bevy_mod_scripting_lua_derive/src/lib.rs | 845 +- .../src/lua_method.rs | 266 - .../src/visitor.rs | 224 +- .../tests/macro_tests.rs | 8 +- .../tests/{ => success/containers}/result.rs | 0 languages/bevy_mod_scripting_rhai/Cargo.toml | 12 +- languages/bevy_mod_scripting_rhai/src/lib.rs | 2 +- .../bevy_mod_scripting_rhai_derive/src/lib.rs | 2 - .../src/rhai_method.rs | 29 - makefile | 59 +- sailfish.toml | 1 + templates/footer.stpl | 74 + templates/function.stpl | 58 + templates/header.stpl | 22 + templates/header_per_item.stpl | 0 templates/item.stpl | 25 + templates/main.stpl | 11 + 50 files changed, 89704 insertions(+), 14559 deletions(-) create mode 100644 .vscode/tasks.json delete mode 100644 bevy_mod_scripting_common/src/arg.rs delete mode 100644 bevy_mod_scripting_common/src/derive_data.rs delete mode 100644 bevy_mod_scripting_common/src/derive_flag.rs delete mode 100644 bevy_mod_scripting_common/src/implementor.rs delete mode 100644 bevy_mod_scripting_common/src/newtype.rs delete mode 100644 bevy_mod_scripting_common/src/ops.rs delete mode 100644 languages/bevy_mod_scripting_lua_derive/src/derive_flags/auto_methods.rs delete mode 100644 languages/bevy_mod_scripting_lua_derive/src/derive_flags/bin_ops.rs delete mode 100644 languages/bevy_mod_scripting_lua_derive/src/derive_flags/fields.rs delete mode 100644 languages/bevy_mod_scripting_lua_derive/src/derive_flags/mod.rs delete mode 100644 languages/bevy_mod_scripting_lua_derive/src/derive_flags/unary_ops.rs delete mode 100644 languages/bevy_mod_scripting_lua_derive/src/implementor.rs delete mode 100644 languages/bevy_mod_scripting_lua_derive/src/impls.rs delete mode 100644 languages/bevy_mod_scripting_lua_derive/src/lua_method.rs rename languages/bevy_mod_scripting_lua_derive/tests/{ => success/containers}/result.rs (100%) delete mode 100644 languages/bevy_mod_scripting_rhai_derive/src/rhai_method.rs create mode 100644 sailfish.toml create mode 100644 templates/footer.stpl create mode 100644 templates/function.stpl create mode 100644 templates/header.stpl create mode 100644 templates/header_per_item.stpl create mode 100644 templates/item.stpl create mode 100644 templates/main.stpl diff --git a/.vscode/launch.json b/.vscode/launch.json index 07adf3530a..a6483eca38 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,30 +1,20 @@ { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "lldb", "request": "launch", - "name": "Debug unit tests in library 'bevy_mod_scripting'", - "cargo": { - "args": [ - "test", - "--no-run", - "--lib", - "--package=bevy_mod_scripting" - ], - "filter": { - "name": "bevy_mod_scripting", - "kind": "lib" - } - }, - "args": [], + "name": "Debug specific unit test", + "preLaunchTask": "Build specific package's unit tests", + "program": "${workspaceFolder}/target/debug/test_binary", "env": { - "CARGO_MANIFEST_DIR": "${workspaceFolder}/bevy_mod_scripting" + "CARGO_MANIFEST_DIR": "${workspaceFolder}/bevy_mod_scripting", + "LD_LIBRARY_PATH": "${workspaceFolder}/target/debug/deps:${env:HOME}/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib" }, - "cwd": "${workspaceFolder}" + "cwd": "${workspaceFolder}", }, { "name": "Debug example 'game_of_life_lua'", @@ -45,7 +35,8 @@ "args": [], "cwd": "${workspaceFolder}", "env": { - "CARGO_MANIFEST_DIR": "${workspaceFolder}" + "CARGO_MANIFEST_DIR": "${workspaceFolder}", + "LD_LIBRARY_PATH": "${workspaceFolder}/target/debug/deps:${env:HOME}/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib" } }, { diff --git a/.vscode/settings.json b/.vscode/settings.json index a38c6b2d0c..1bdb3b75f3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -13,6 +13,9 @@ "rust-analyzer.server.extraEnv": { "RUSTUP_TOOLCHAIN": "stable" }, + "rust-analyzer.runnables.extraEnv": { + "LD_LIBRARY_PATH": "${workspaceFolder}/target/debug/deps:${env:HOME}/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib" + }, "[rust]": { "editor.formatOnSave": true, "editor.formatOnSaveMode": "file", diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000000..14262c18e9 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,29 @@ +{ + "version": "2.0.0", + "inputs": [ + { + "id": "test_name", + "type": "promptString", + "description": "Run only tests including this string in their name", + "default": "" + }, + { + "id": "package", + "type": "promptString", + "description": "The crate location of this unit test", + "default": "bevy_mod_scripting" + } + ], + "tasks": [ + { + "label": "Build specific package's unit tests", + "type": "process", + "command": "make", + "args": [ + "build_test_in_package", + "PACKAGE=${input:package}", + "TEST_NAME=${input:test_name}" + ] + } + ] +} \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 749a5df6e6..a29abed0f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,7 +69,7 @@ bevy_script_api = { path = "bevy_script_api", version = "0.3.0", optional = true bevy = { version = "0.11" } clap = { version = "4.1", features = ["derive"] } rand = "0.8.5" -bevy_console = "0.8.0" +bevy_console = "0.9.0" rhai-rand = "0.1" [workspace] @@ -93,7 +93,6 @@ opt-level = 1 [profile.dev.package."*"] opt-level = 3 - [[example]] name = "console_integration_lua" path = "examples/lua/console_integration.rs" diff --git a/bevy_api_gen/Cargo.toml b/bevy_api_gen/Cargo.toml index b215f1544a..847a4377bb 100644 --- a/bevy_api_gen/Cargo.toml +++ b/bevy_api_gen/Cargo.toml @@ -7,13 +7,13 @@ license = "MIT" description = "A code generator creating macro invocations to support the changing bevy API" repository = "https://github.com/makspll/bevy_mod_scripting" homepage = "https://github.com/makspll/bevy_mod_scripting" -keywords = ["bevy", "gamedev", "scripting", "lua","code-generation"] +keywords = ["bevy", "gamedev", "scripting", "lua", "code-generation"] categories = ["game-development"] readme = "readme.md" [package.metadata.release] pre-release-replacements = [ - {file="Cargo.toml", search='^version\s*=\s*.*$', replace="version = \"{{version}}\"", exactly=1}, + { file = "Cargo.toml", search = '^version\s*=\s*.*$', replace = "version = \"{{version}}\"", exactly = 1 }, ] [lib] @@ -26,10 +26,19 @@ path = "src/main.rs" [dependencies] -rustdoc-types = "0.22.0" -clap = { version = "3.2.6", features = ["derive"] } + +log = "0.4.20" +pretty_env_logger = "0.5.0" +sailfish = "0.8.3" +rustdoc-types = "0.23.0" +clap = { version = "4.4.7", features = ["derive"] } serde_json = "1.0.81" -toml = "0.5.9" +toml = "0.8.6" serde = { version = "1.0", features = ["derive"] } serde_derive = "1.0.137" -indexmap = {version= "1.9.1", features= ["serde"]} +indexmap = { version = "2.1.0", features = ["serde"] } +prettyplease = "0.2.15" +syn = { version = "2", default-features = false, features = [ + "full", + "parsing", +] } diff --git a/bevy_api_gen/src/arg_validator.rs b/bevy_api_gen/src/arg_validator.rs index 6b21df3b4a..46ae7130c1 100644 --- a/bevy_api_gen/src/arg_validator.rs +++ b/bevy_api_gen/src/arg_validator.rs @@ -1,13 +1,15 @@ use rustdoc_types::{GenericArg, GenericArgs, Type}; /// A representation of valid argument types -#[derive(Debug)] +#[derive(Debug, Clone)] pub enum ArgType { /// The primary identifier of the type /// /// Valid types right now follow the following syntax: /// `(&)? (mut)? ident:ident` - Self_, + Self_ { + in_receiver_position: bool, + }, Base(String), Generic { base: Box, @@ -38,7 +40,15 @@ impl fmt::Display for ArgType { ref_.fmt(f) } - ArgType::Self_ => f.write_str("self"), + ArgType::Self_ { + in_receiver_position, + } => { + if *in_receiver_position { + f.write_str("self") + } else { + f.write_str("Self") + } + } ArgType::Generic { base, args } => { base.fmt(f)?; f.write_str("<")?; @@ -54,18 +64,10 @@ impl fmt::Display for ArgType { } } -impl TryFrom for ArgType { - type Error = String; - - fn try_from(value: Type) -> Result { - Self::try_from(&value) - } -} - -impl TryFrom<&Type> for ArgType { +impl TryFrom<(bool, &Type)> for ArgType { type Error = String; - fn try_from(value: &Type) -> Result { + fn try_from((is_receiver, value): (bool, &Type)) -> Result { match value { Type::ResolvedPath(path) => { let mut processed_args = Vec::default(); @@ -74,7 +76,9 @@ impl TryFrom<&Type> for ArgType { if let GenericArgs::AngleBracketed { args, bindings } = a.as_ref() { for generic in args { match generic { - GenericArg::Type(type_) => processed_args.push(type_.try_into()?), + GenericArg::Type(type_) => { + processed_args.push((is_receiver, type_).try_into()?) + } _ => { return Err( "Only types are allowed as generic arguments".to_owned() @@ -89,7 +93,7 @@ impl TryFrom<&Type> for ArgType { return Err("Parenthesised generics are not supported".to_owned()); } } - let base = Type::Primitive(path.name.to_string()).try_into()?; + let base = (is_receiver, &Type::Primitive(path.name.to_string())).try_into()?; if let base @ ArgType::Base(_) = base { if !processed_args.is_empty() { Ok(Self::Generic { @@ -104,50 +108,56 @@ impl TryFrom<&Type> for ArgType { } } Type::Primitive(name) | Type::Generic(name) => { - if name == "Self" { - Ok(Self::Self_) + if name == "Self" || is_receiver { + Ok(Self::Self_ { + in_receiver_position: is_receiver, + }) } else { Ok(Self::Base(name.split("::").last().unwrap().to_owned())) } } Type::BorrowedRef { mutable, type_, .. } => Ok(Self::Ref { is_mut: *mutable, - ref_: Box::new(type_.as_ref().try_into()?), + ref_: Box::new((is_receiver, type_.as_ref()).try_into()?), }), - _ => Err("".to_owned()), + _ => Err("ArgType is not supported".to_owned()), } } } impl ArgType { - /// Produce an arbitrary output given the base identifier of this type or err if this is the base is a self receiver - pub fn map_base(&self, f: F) -> O + /// Modify base and return modified self + pub fn map_base_mut(&mut self, f: F) -> &mut Self where - F: FnOnce(Result<&String, ()>) -> O, + F: FnOnce(&mut String), { match self { - ArgType::Base(b) => f(Ok(b)), - ArgType::Ref { is_mut: _, ref_ } => ref_.map_base(f), - ArgType::Self_ => f(Err(())), - ArgType::Generic { base, .. } => base.map_base(f), - } + ArgType::Base(b) => f(b), + ArgType::Ref { is_mut: _, ref_ } => _ = ref_.map_base_mut(f), + ArgType::Generic { base, .. } => _ = base.map_base_mut(f), + _ => (), + }; + self } - /// Produce an arbitrary output given the base identifier of this type, and optionally modify it - pub fn map_base_mut(&mut self, f: F) -> O - where - F: FnOnce(Result<&mut String, ()>) -> O, - { + pub fn is_receiver(&self) -> bool { match self { - ArgType::Base(b) => f(Ok(b)), - ArgType::Ref { is_mut: _, ref_ } => ref_.map_base_mut(f), - ArgType::Self_ => f(Err(())), - ArgType::Generic { base, .. } => base.map_base_mut(f), + ArgType::Self_ { + in_receiver_position, + } => *in_receiver_position, + ArgType::Generic { base, .. } => base.is_receiver(), + ArgType::Ref { ref_, .. } => ref_.is_receiver(), + _ => false, } } - pub fn is_self(&self) -> bool { - self.map_base(|b| b.is_err()) + pub fn is_contextual(&self) -> bool { + match self { + ArgType::Self_ { .. } => true, + ArgType::Generic { base, .. } => base.is_receiver(), + ArgType::Ref { ref_, .. } => ref_.is_receiver(), + _ => false, + } } /// Retrieves the base ident if this type is resolved otherwise returns None (i.e. in the case of a self receiver) @@ -155,7 +165,7 @@ impl ArgType { match self { ArgType::Base(b) => Some(b), ArgType::Ref { is_mut: _, ref_ } => ref_.base_ident(), - ArgType::Self_ => None, + ArgType::Self_ { .. } => None, ArgType::Generic { base, .. } => base.base_ident(), } } @@ -173,7 +183,7 @@ impl ArgWrapperType { pub fn with_config(self_type: &str, type_: &ArgType, config: &Config) -> Option { let base_ident = type_.base_ident().unwrap_or(self_type); type_ - .is_self() + .is_receiver() .then_some(ArgWrapperType::None) .or_else(|| { config diff --git a/bevy_api_gen/src/config.rs b/bevy_api_gen/src/config.rs index 7909dbf874..af6dd76d4e 100644 --- a/bevy_api_gen/src/config.rs +++ b/bevy_api_gen/src/config.rs @@ -1,7 +1,10 @@ +use std::collections::HashSet; + use clap::Parser; use indexmap::{IndexMap, IndexSet}; use rustdoc_types::{Crate, Item, ItemEnum, Visibility}; use serde::Deserialize; +use serde_derive::Serialize; #[derive(Parser, Debug)] #[clap(author, version, about, long_about = None)] @@ -14,12 +17,21 @@ pub struct Args { #[clap(short, long, value_parser)] pub config: String, + #[clap(short, long, value_parser, default_value = "templates")] + pub templates: String, + + #[clap(short, long, value_parser, default_value = "generated.rs")] + pub output: String, + + #[clap(short, long, value_parser, num_args(0..))] + pub type_allowlist: Option>, + /// if true the excluded methods will show up as commented out code with reasons for exclusion #[clap(long)] pub print_errors: bool, } -#[derive(Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug)] pub struct Config { #[serde(skip_deserializing, default)] pub types: IndexMap, @@ -39,7 +51,7 @@ pub struct Config { pub manual_lua_types: Vec, } -#[derive(Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug)] pub struct ManualLuaType { pub name: String, @@ -60,7 +72,7 @@ pub struct ManualLuaType { pub use_dummy_proxy: bool, } -#[derive(Deserialize, Debug, Hash, PartialEq, Eq)] +#[derive(Serialize, Deserialize, Debug, Hash, PartialEq, Eq)] pub struct Newtype { #[serde(rename = "type")] pub type_: String, @@ -84,13 +96,13 @@ pub struct Newtype { pub traits: Vec, } -#[derive(Deserialize, Debug, PartialEq, Eq, Hash, Default)] +#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash, Default)] pub struct TraitMethods { pub name: String, pub import_path: String, } -#[derive(Deserialize, Debug, PartialEq, Eq, Hash)] +#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash)] pub struct Source(pub String); impl Default for Source { diff --git a/bevy_api_gen/src/cratepath.rs b/bevy_api_gen/src/cratepath.rs index 7c5ab3fc13..250099c6a8 100644 --- a/bevy_api_gen/src/cratepath.rs +++ b/bevy_api_gen/src/cratepath.rs @@ -1,6 +1,46 @@ use rustdoc_types::{Crate, Id, ItemEnum, Visibility}; +pub(crate) fn crate_name(crate_: &Crate) -> String { + crate_ + .index + .get(&crate_.root) + .as_ref() + .unwrap() + .name + .to_owned() + .unwrap() +} + +pub(crate) fn lookup_external_item_crate_source_name(id: &Id, found_in: &Crate) -> String { + let crate_id = found_in + .paths + .get(id) + .expect("Missing link to external item") + .crate_id; + found_in + .external_crates + .get(&crate_id) + .unwrap() + .name + .to_owned() +} + +pub(crate) fn lookup_item_crate_source<'a>(id: &'a Id, crates: &'a [Crate]) -> Option<&'a Crate> { + crates.iter().find(|crate_| crate_.index.contains_key(id)) +} + pub(crate) fn get_path(id: &Id, source: &Crate) -> Option> { + log::debug!( + "Trying to find path for item id: `{id:?}` has index entry: `{}` has path entry: `{}`", + source.index.get(id).is_some(), + source.paths.get(id).is_some() + ); + if source.index.get(id).is_none() { + panic!("Trying to find path for item which is external to the provided source crate, the item lives in crate: `{}` not in `{}`", + source.external_crates.get(&source.paths.get(id).as_ref().unwrap().crate_id).unwrap().name, + crate_name(source) + ); + } match source.paths.get(id) { Some(_) => return Some(vec![id.to_owned()]), None => { @@ -44,13 +84,31 @@ pub(crate) fn get_path(id: &Id, source: &Crate) -> Option> { } pub(crate) fn path_to_import(path: Vec, source: &Crate) -> Vec { + log::debug!( + "Trying to convert id path to path components: `{path:?}` with names: [{:?}] in crate: `{}`", + path.iter() + .map(|id| source + .index + .get(id) + .and_then(|item| item.name.as_deref()) + .unwrap_or("None")) + .collect::>() + .join(","), + crate_name(source) + ); path.iter() .rev() .enumerate() .rev() .enumerate() .map(|(starti, (endi, id))| { - let ind = source.index.get(id).unwrap(); + log::trace!("starti: {starti}, endi: {endi}, id: {id:?}"); + + let ind = source + .index + .get(id) + .expect("Trying to find path to item which is not in the provided source crate"); + if starti == 0 { return source.paths.get(id).unwrap().path.clone(); } else if endi == 0 { diff --git a/bevy_api_gen/src/main.rs b/bevy_api_gen/src/main.rs index e47e1f508c..0727fd342b 100644 --- a/bevy_api_gen/src/main.rs +++ b/bevy_api_gen/src/main.rs @@ -1,17 +1,22 @@ pub mod cratepath; -use bevy_api_gen_lib::{Args, Config, PrettyWriter, WrappedItem, WRAPPER_PREFIX}; +use bevy_api_gen_lib::{ArgType, Args, Config, Newtype, PrettyWriter, TypeMeta, WRAPPER_PREFIX}; use clap::Parser; -use cratepath::{get_path, path_to_import}; +use cratepath::{ + get_path, lookup_external_item_crate_source_name, lookup_item_crate_source, path_to_import, +}; use indexmap::{IndexMap, IndexSet}; -use rustdoc_types::{Crate, Impl, Item, ItemEnum}; +use rustdoc_types::{Crate, Impl, Item, ItemEnum, Type}; +use sailfish::{runtime::Buffer, TemplateOnce}; use serde_json::from_reader; use std::{ borrow::Cow, collections::HashSet, + error::Error, + fmt::Display, fs::{read_to_string, File}, - io::{self, BufReader}, + io::{self, BufReader, Write}, }; pub(crate) fn write_use_items_from_path( @@ -37,15 +42,248 @@ pub(crate) fn write_use_items_from_path( writer.newline(); } -pub(crate) fn generate_macros( - crates: &[Crate], - config: Config, - args: &Args, -) -> Result { +// pub(crate) fn generate_macros( +// crates: &[Crate], +// config: Config, +// args: &Args, +// ) -> Result { +// writer.write_line("#![allow(clippy::all,unused_imports)]"); +// writer.write_line("// This file is generated by `bevy_mod_scripting_derive/main.rs` change the template not this file"); +// writer.write_line("extern crate self as bevy_script_api;"); +// writer.write_line("use bevy_mod_scripting_derive::impl_script_newtype;"); + +// // user defined +// config.imports.lines().for_each(|import| { +// writer.write_line(import); +// }); +// // automatic + +// wrapped_items.iter().for_each(|item| { +// write_use_items_from_path( +// &item.config.source.0, +// &item.path_components[1..], +// &mut writer, +// ); +// }); + +// let mut imported = HashSet::::default(); + +// wrapped_items.iter().for_each(|item| { +// item.config.traits.iter().for_each(|trait_methods| { +// if !imported.contains(&trait_methods.name) { +// writer.write_no_newline("use "); +// writer.write_inline(&trait_methods.import_path); +// writer.write_inline(";"); +// writer.newline(); +// imported.insert(trait_methods.name.to_owned()); +// } +// }) +// }); + +// // make macro calls for each wrapped item +// wrapped_items.iter_mut().for_each(|v| { +// // macro invocation +// writer.write_no_newline("impl_script_newtype!"); +// writer.open_brace(); +// writer.write_line("#[languages(on_feature(lua))]"); + +// v.write_type_docstring(&mut writer, args); +// writer.write_indentation(); +// v.write_inline_full_path(&mut writer, args); +// writer.write_inline(" : "); +// writer.newline(); + +// v.write_derive_flags_body(&config, &mut writer, args); + +// writer.write_line("lua impl"); +// writer.open_brace(); +// v.write_impl_block_body(&mut writer, args); +// writer.close_brace(); + +// writer.close_brace(); +// }); + +// // write other code +// for line in config.other.lines() { +// writer.write_line(line); +// } + +// // now create the BevyAPIProvider +// // first the globals +// writer.write_line("#[cfg(feature=\"lua\")]"); +// writer.write_line("#[derive(Default)]"); +// writer.write_line("pub(crate) struct BevyAPIGlobals;"); + +// writer.write_line("#[cfg(feature=\"lua\")]"); +// writer.write_no_newline( +// "impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for BevyAPIGlobals", +// ); +// writer.open_brace(); +// writer.write_line("fn add_instances<'lua, T: bevy_mod_scripting_lua::tealr::mlu::InstanceCollector<'lua>>(self, instances: &mut T) -> bevy_mod_scripting_lua::tealr::mlu::mlua::Result<()>"); +// writer.open_brace(); +// for (global_name, type_, dummy_proxy) in wrapped_items +// .iter() +// .filter_map(|i| { +// i.has_global_methods.then_some(( +// i.wrapped_type.as_str(), +// i.wrapper_name.as_str(), +// false, +// )) +// }) +// .chain(config.manual_lua_types.iter().filter_map(|i| { +// i.include_global_proxy.then_some(( +// i.proxy_name.as_str(), +// i.name.as_str(), +// i.use_dummy_proxy, +// )) +// })) +// { +// writer.write_no_newline("instances.add_instance("); +// // type name +// writer.write_inline("\""); +// writer.write_inline(global_name); +// writer.write_inline("\""); +// // corresponding proxy +// if dummy_proxy { +// writer.write_inline(", crate::lua::util::DummyTypeName::<"); +// writer.write_inline(type_); +// writer.write_inline(">::new"); +// writer.write_inline(")?;"); +// writer.newline(); +// } else { +// writer.write_inline(", bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::<"); +// writer.write_inline(type_); +// writer.write_inline(">::new)?;"); +// writer.newline(); +// } +// } + +// writer.write_line("Ok(())"); +// writer.close_brace(); +// writer.close_brace(); + +// // then the actual provider +// writer.write_line("#[cfg(feature=\"lua\")]"); +// writer.write_line("pub struct LuaBevyAPIProvider;"); + +// // begin impl { +// writer.write_line("#[cfg(feature=\"lua\")]"); +// writer.write_no_newline("impl APIProvider for LuaBevyAPIProvider"); +// writer.open_brace(); + +// writer.write_line("type APITarget = Mutex;"); +// writer.write_line("type ScriptContext = Mutex;"); +// writer.write_line("type DocTarget = LuaDocFragment;"); + +// // attach_api { +// writer.write_no_newline( +// "fn attach_api(&mut self, ctx: &mut Self::APITarget) -> Result<(), ScriptError>", +// ); +// writer.open_brace(); +// writer.write_line("let ctx = ctx.get_mut().expect(\"Unable to acquire lock on Lua context\");"); +// writer.write_line("bevy_mod_scripting_lua::tealr::mlu::set_global_env(BevyAPIGlobals,ctx).map_err(|e| ScriptError::Other(e.to_string()))"); +// writer.close_brace(); +// // } attach_api + +// // get_doc_fragment +// writer.write_no_newline("fn get_doc_fragment(&self) -> Option"); +// writer.open_brace(); +// writer.write_no_newline("Some(LuaDocFragment::new(\"BevyAPI\", |tw|"); +// writer.open_brace(); +// writer.write_line("tw"); +// writer.write_line(".document_global_instance::().expect(\"Something went wrong documenting globals\")"); + +// // include external types not generated by this file as well +// for (type_, include_proxy) in +// wrapped_items +// .iter() +// .map(|i| (i.wrapper_name.as_str(), i.has_global_methods)) +// .chain(config.manual_lua_types.iter().filter_map(|i| { +// (!i.dont_process).then_some((i.name.as_str(), i.include_global_proxy)) +// })) +// { +// writer.write_no_newline(".process_type::<"); +// writer.write_inline(type_); +// writer.write_inline(">()"); +// writer.newline(); + +// if include_proxy { +// writer.write_no_newline( +// ".process_type::>()"); +// writer.newline(); +// } +// } + +// writer.close_brace(); +// writer.write_line("))"); + +// writer.close_brace(); +// // } get_doc_fragment + +// // impl default members +// for line in config.lua_api_defaults.lines() { +// writer.write_line(line); +// } + +// // register_with_app { +// writer.write_no_newline("fn register_with_app(&self, app: &mut App)"); +// writer.open_brace(); +// for item in wrapped_items +// .iter() +// .map(|i| i.wrapped_type) +// .chain(config.primitives.iter()) +// { +// writer.write_no_newline("app.register_foreign_lua_type::<"); +// writer.write_inline(item); +// writer.write_inline(">();"); +// writer.newline(); +// } +// writer.close_brace(); +// // } regiser_with_app + +// writer.close_brace(); +// // } end impl + +// Ok(writer.finish()) +// } + +pub fn main() -> Result<(), io::Error> { + let args = Args::parse(); + + let crates: Vec<_> = args + .json + .iter() + .map(|json| { + let f = File::open(json).unwrap_or_else(|e| panic!("Could not open {}, {e}", &json)); + let rdr = BufReader::new(f); + from_reader(rdr) + }) + .collect::, _>>()?; + + let f = read_to_string(&args.config)?; + let mut config: Config = + toml::from_str(&f).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?; + + config.types_.reverse(); + + while !config.types_.is_empty() { + let t = config.types_.remove(config.types_.len() - 1); + config.types.insert(t.type_.to_string(), t); + } + + generate(crates, config, args); + + Ok(()) +} + +fn generate_macro_data<'a>(crates: &'a [Crate], config: &'a Config) -> Vec> { // the items we want to generate macro instantiations for let mut unmatched_types: HashSet<&String> = config.types.iter().map(|(k, _v)| k).collect(); - let mut wrapped_items: Vec<_> = crates + let mut type_meta: Vec<_> = crates .iter() .flat_map(|source| { source @@ -93,17 +331,14 @@ pub(crate) fn generate_macros( let config = config.types.get(item.name.as_ref().unwrap()).unwrap(); - //let path_components = &source.paths.get(id).unwrap().path; let path_components = get_path(id, source).unwrap_or_else(|| { panic!("path not found for {:?} in {:?}", id, source.root) }); - //eprintln!("{:?}", path_components); let path_components = path_to_import(path_components, source); - //eprintln!("{:?}", path_components); let wrapper_name = format!("{WRAPPER_PREFIX}{}", item.name.as_ref().unwrap()); let wrapped_type = item.name.as_ref().unwrap(); - WrappedItem { + TypeMeta { wrapper_name, wrapped_type, path_components: Cow::Owned(path_components), @@ -120,248 +355,272 @@ pub(crate) fn generate_macros( }) .collect(); - wrapped_items.iter().for_each(|v| { + type_meta.iter().for_each(|v| { unmatched_types.remove(&v.wrapped_type); }); if !unmatched_types.is_empty() { panic!("Some types were not found in the given crates: {unmatched_types:#?}") } - - let mut writer = PrettyWriter::new(); - // we want to preserve the original ordering from the config file - wrapped_items.sort_by_cached_key(|f| config.types.get_index_of(f.wrapped_type).unwrap()); + type_meta.sort_by_cached_key(|f| config.types.get_index_of(f.wrapped_type).unwrap()); - writer.write_line("#![allow(clippy::all,unused_imports)]"); - writer.write_line("// This file is generated by `bevy_mod_scripting_derive/main.rs` change the template not this file"); - writer.write_line("extern crate self as bevy_script_api;"); - writer.write_line("use bevy_mod_scripting_derive::impl_script_newtype;"); + type_meta +} - // user defined - config.imports.lines().for_each(|import| { - writer.write_line(import); - }); - // automatic +fn unwrap_or_pretty_error(val: Result) -> T { + match val { + Ok(v) => v, + Err(e) => panic!("{}", e), + } +} - wrapped_items.iter().for_each(|item| { - write_use_items_from_path( - &item.config.source.0, - &item.path_components[1..], - &mut writer, - ); - }); +#[derive(Debug)] +struct FunctionArg { + name: String, + type_: ArgType, + is_proxied: bool, +} - let mut imported = HashSet::::default(); +impl TryFrom<((String, Type), &Config)> for FunctionArg { + type Error = Box; + + fn try_from(((name, type_), config): ((String, Type), &Config)) -> Result { + let type_: ArgType = (name == "self", &type_).try_into()?; + + let is_primitive = type_ + .base_ident() + .is_some_and(|ident| config.primitives.contains(ident)); + + let is_proxied = type_.is_contextual() + || (!is_primitive + && type_ + .base_ident() + .is_some_and(|ident| config.types.contains_key(ident))); + if !is_primitive && !is_proxied { + return Err(format!( + "Type is neither a wrapped type in the config or an allowed primitive: `{type_:?}`" + ) + .into()); + } - wrapped_items.iter().for_each(|item| { - item.config.traits.iter().for_each(|trait_methods| { - if !imported.contains(&trait_methods.name) { - writer.write_no_newline("use "); - writer.write_inline(&trait_methods.import_path); - writer.write_inline(";"); - writer.newline(); - imported.insert(trait_methods.name.to_owned()); - } + Ok(Self { + name, + type_, + is_proxied, }) - }); - - // make macro calls for each wrapped item - wrapped_items.iter_mut().for_each(|v| { - // macro invocation - writer.write_no_newline("impl_script_newtype!"); - writer.open_brace(); - writer.write_line("#[languages(on_feature(lua))]"); + } +} - v.write_type_docstring(&mut writer, args); - writer.write_indentation(); - v.write_inline_full_path(&mut writer, args); - writer.write_inline(" : "); - writer.newline(); +struct FunctionData { + is_static: bool, + args: Vec, + output: Option, + trait_path: Option, + docstrings: Vec, +} - v.write_derive_flags_body(&config, &mut writer, args); +impl TryFrom<(Option, Item, &Config)> for FunctionData { + type Error = Box; - writer.write_line("lua impl"); - writer.open_brace(); - v.write_impl_block_body(&mut writer, args); - writer.close_brace(); + fn try_from( + (trait_path, item, config): (Option, Item, &Config), + ) -> Result { + let (decl, generics) = match item.inner { + ItemEnum::Function(f) => (f.decl, f.generics), + _ => return Err("Not a function item".into()), + }; - writer.close_brace(); - }); + log::trace!("Converting function: {}", item.name.unwrap()); + log::trace!("inputs: {:?}", decl.inputs); - // write other code - for line in config.other.lines() { - writer.write_line(line); - } + if !generics.params.is_empty() { + return Err("Generics are not supported".into()); + } - // now create the BevyAPIProvider - // first the globals - writer.write_line("#[cfg(feature=\"lua\")]"); - writer.write_line("#[derive(Default)]"); - writer.write_line("pub(crate) struct BevyAPIGlobals;"); - - writer.write_line("#[cfg(feature=\"lua\")]"); - writer.write_no_newline( - "impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for BevyAPIGlobals", - ); - writer.open_brace(); - writer.write_line("fn add_instances<'lua, T: bevy_mod_scripting_lua::tealr::mlu::InstanceCollector<'lua>>(self, instances: &mut T) -> bevy_mod_scripting_lua::tealr::mlu::mlua::Result<()>"); - writer.open_brace(); - for (global_name, type_, dummy_proxy) in wrapped_items - .iter() - .filter_map(|i| { - i.has_global_methods.then_some(( - i.wrapped_type.as_str(), - i.wrapper_name.as_str(), - false, - )) + let args = decl + .inputs + .into_iter() + .map(|(name, type_)| ((name, type_), config).try_into()) + .collect::, _>>()?; + + let is_static = args + .first() + .map(|first: &FunctionArg| !first.type_.is_receiver()) + .unwrap_or(true); + + log::trace!( + "function is static?: {is_static}, first arg: {:?}, is_receiver: {:?}", + args.first(), + args.first().map(|arg| arg.type_.is_receiver()) + ); + let output = decl + .output + .map(|type_| { + // any idx apart from 0, don't want receivers here + (("output".to_owned(), type_), config) + .try_into() + .and_then(|arg: FunctionArg| { + (!matches!(arg.type_, ArgType::Ref { .. })) + .then_some(arg) + .ok_or("Reference are not supported in output position".into()) + }) + }) + .transpose()?; + + let docstrings = item + .docs + .unwrap_or("".to_owned()) + .lines() + .map(|s| s.to_owned()) + .collect(); + Ok(Self { + is_static, + args, + output, + docstrings, + trait_path, }) - .chain(config.manual_lua_types.iter().filter_map(|i| { - i.include_global_proxy.then_some(( - i.proxy_name.as_str(), - i.name.as_str(), - i.use_dummy_proxy, - )) - })) - { - writer.write_no_newline("instances.add_instance("); - // type name - writer.write_inline("\""); - writer.write_inline(global_name); - writer.write_inline("\""); - // corresponding proxy - if dummy_proxy { - writer.write_inline(", crate::lua::util::DummyTypeName::<"); - writer.write_inline(type_); - writer.write_inline(">::new"); - writer.write_inline(")?;"); - writer.newline(); - } else { - writer.write_inline(", bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::<"); - writer.write_inline(type_); - writer.write_inline(">::new)?;"); - writer.newline(); - } } +} + +struct ItemData { + source_crate: String, + import_path: ImportPath, + implemented_traits: IndexSet, + functions: IndexMap, + docstrings: Vec, +} - writer.write_line("Ok(())"); - writer.close_brace(); - writer.close_brace(); - - // then the actual provider - writer.write_line("#[cfg(feature=\"lua\")]"); - writer.write_line("pub struct LuaBevyAPIProvider;"); - - // begin impl { - writer.write_line("#[cfg(feature=\"lua\")]"); - writer.write_no_newline("impl APIProvider for LuaBevyAPIProvider"); - writer.open_brace(); - - writer.write_line("type APITarget = Mutex;"); - writer.write_line("type ScriptContext = Mutex;"); - writer.write_line("type DocTarget = LuaDocFragment;"); - - // attach_api { - writer.write_no_newline( - "fn attach_api(&mut self, ctx: &mut Self::APITarget) -> Result<(), ScriptError>", - ); - writer.open_brace(); - writer.write_line("let ctx = ctx.get_mut().expect(\"Unable to acquire lock on Lua context\");"); - writer.write_line("bevy_mod_scripting_lua::tealr::mlu::set_global_env(BevyAPIGlobals,ctx).map_err(|e| ScriptError::Other(e.to_string()))"); - writer.close_brace(); - // } attach_api - - // get_doc_fragment - writer.write_no_newline("fn get_doc_fragment(&self) -> Option"); - writer.open_brace(); - writer.write_no_newline("Some(LuaDocFragment::new(\"BevyAPI\", |tw|"); - writer.open_brace(); - writer.write_line("tw"); - writer.write_line(".document_global_instance::().expect(\"Something went wrong documenting globals\")"); - - // include external types not generated by this file as well - for (type_, include_proxy) in - wrapped_items - .iter() - .map(|i| (i.wrapper_name.as_str(), i.has_global_methods)) - .chain(config.manual_lua_types.iter().filter_map(|i| { - (!i.dont_process).then_some((i.name.as_str(), i.include_global_proxy)) - })) - { - writer.write_no_newline(".process_type::<"); - writer.write_inline(type_); - writer.write_inline(">()"); - writer.newline(); - - if include_proxy { - writer.write_no_newline( - ".process_type::>()"); - writer.newline(); +impl From<(TypeMeta<'_>, &Config)> for ItemData { + fn from((meta, config): (TypeMeta<'_>, &Config)) -> Self { + let import_path: Vec = meta.path_components.into(); + let import_path: ImportPath = import_path.into(); + + Self { + source_crate: meta.config.source.0.to_owned(), + import_path, + implemented_traits: meta.implemented_traits, + functions: meta + .impl_items + .iter() + .flat_map(|(name, impl_items)| { + impl_items.iter().filter_map(move |(impl_, item)| { + let trait_path = impl_ + .trait_ + .as_ref() + .map(|trait_| { + // TODO: this is probably pretty slow, pre-calculate this + // meta.crates.iter().find_map(|crate_| + + let origin_crate = + lookup_item_crate_source(&trait_.id, meta.crates).ok_or( + format!( + "Could not find trait in any crates `{}`", + trait_.name + ), + )?; + + let path_components = get_path(&trait_.id, origin_crate).unwrap(); + let import_path = + path_to_import(path_components, meta.source).into(); + Ok(import_path) + }) + .transpose() + .map_err(|e: Box| { + log::info!( + "Skipping trait impl in type: `{}` because: `{}`", + meta.config.type_, + e + ) + }) + .ok()?; + + let fn_item = (trait_path, (*item).clone(), config) + .try_into() + .map_err(|e| { + log::info!( + "Skipping function: `{}` in type: `{}` due to: `{e}`", + name, + meta.config.type_ + ); + e + }) + .ok()?; + + Some((name.to_string(), fn_item)) + }) + // }) + }) + .collect(), + docstrings: vec![], } } +} - writer.close_brace(); - writer.write_line("))"); - - writer.close_brace(); - // } get_doc_fragment +#[derive(Clone)] +struct ImportPath { + pub components: Vec, +} - // impl default members - for line in config.lua_api_defaults.lines() { - writer.write_line(line); +impl From> for ImportPath { + fn from(value: Vec) -> Self { + Self { components: value } } +} - // register_with_app { - writer.write_no_newline("fn register_with_app(&self, app: &mut App)"); - writer.open_brace(); - for item in wrapped_items - .iter() - .map(|i| i.wrapped_type) - .chain(config.primitives.iter()) - { - writer.write_no_newline("app.register_foreign_lua_type::<"); - writer.write_inline(item); - writer.write_inline(">();"); - writer.newline(); +impl Display for ImportPath { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(self.components.join("::").as_str()) } - writer.close_brace(); - // } regiser_with_app - - writer.close_brace(); - // } end impl - - Ok(writer.finish()) } -pub fn main() -> Result<(), io::Error> { - let args = Args::parse(); - - let crates: Vec<_> = args - .json - .iter() - .map(|json| { - let f = File::open(json).unwrap_or_else(|_| panic!("Could not open {}", &json)); - let rdr = BufReader::new(f); - from_reader(rdr) - }) - .collect::, _>>()?; - - let f = read_to_string(&args.config)?; - let mut config: Config = toml::from_str(&f)?; - - config.types_.reverse(); - - while !config.types_.is_empty() { - let t = config.types_.remove(config.types_.len() - 1); - config.types.insert(t.type_.to_string(), t); +impl ImportPath { + pub fn replace_prefix(&self, prefix: &str, replacement: &str) -> Self { + let mut components = self.components.clone(); + if let Some(first) = components.first_mut() { + if let Some(stripped) = first.strip_prefix(prefix) { + *first = replacement.to_owned() + stripped; + } + } + Self { components } } +} - let out = generate_macros(&crates, config, &args)?; - - println!("{}", out); +#[derive(TemplateOnce)] +#[template(path = "main.stpl", escape = false)] +struct TemplateData { + items: IndexMap, +} - Ok(()) +fn generate(crates: Vec, config: Config, args: Args) { + pretty_env_logger::init(); + log::info!("Beginning code gen"); + let wrapped_items = generate_macro_data(&crates, &config); + + let mut buffer = Buffer::new(); + + let template_data = TemplateData { + items: wrapped_items + .into_iter() + .filter(|item| { + args.type_allowlist + .as_ref() + .map(|allow_list| allow_list.contains(item.wrapped_type)) + .unwrap_or(true) + }) + .zip(std::iter::repeat(&config)) + .map(ItemData::from) + .map(|i| (i.import_path.components.last().unwrap().to_owned(), i)) + .collect(), + }; + + unwrap_or_pretty_error(template_data.render_once_to(&mut buffer)); + let output = buffer.into_string(); + log::info!("Prettyfying output.."); + let parsed_file = unwrap_or_pretty_error(syn::parse_file(output.as_str())); + let pretty_output = prettyplease::unparse(&parsed_file); + let mut f = unwrap_or_pretty_error(File::create(args.output)); + unwrap_or_pretty_error(f.write_all(pretty_output.as_bytes())); + unwrap_or_pretty_error(f.flush()); } diff --git a/bevy_api_gen/src/wrapper.rs b/bevy_api_gen/src/wrapper.rs index c9a36249d2..053c1974df 100644 --- a/bevy_api_gen/src/wrapper.rs +++ b/bevy_api_gen/src/wrapper.rs @@ -2,13 +2,15 @@ use std::{borrow::Cow, collections::HashSet}; use indexmap::{IndexMap, IndexSet}; use rustdoc_types::{Crate, Id, Impl, Item, ItemEnum, StructKind}; +use serde_derive::Serialize; use crate::{Arg, ArgType, ArgWrapperType, Args, Config, Newtype, PrettyWriter}; pub static WRAPPER_PREFIX: &str = "Lua"; -#[derive(Debug)] -pub struct WrappedItem<'a> { +/// Data describing a macro instance to be generated +#[derive(Serialize, Debug, Clone)] +pub struct TypeMeta<'a> { pub wrapper_name: String, pub wrapped_type: &'a String, pub path_components: Cow<'a, [String]>, @@ -24,7 +26,7 @@ pub struct WrappedItem<'a> { pub has_global_methods: bool, } -impl WrappedItem<'_> { +impl TypeMeta<'_> { /// Writes full type path inline corresponding to `Reflect::type_name` of each type /// /// As: @@ -118,353 +120,353 @@ impl WrappedItem<'_> { }) } - /// Generates all derive flags for the type, - /// - /// Returns additional imports necessary for the generated methods - /// - /// ```rust,ignore - /// my_type::Type : Value: - /// ... // flags go here - /// ``` - pub fn write_derive_flags_body( - &mut self, - config: &Config, - writer: &mut PrettyWriter, - args: &Args, - ) { - if self.implemented_traits.contains("Clone") { - // this flag requires cloning - writer.write_line("Clone +"); - } - - if self.implemented_traits.contains("Debug") { - // this flag requires cloning - writer.write_line("Debug +"); - } - - let mut used_method_identifiers: HashSet<&str> = HashSet::default(); - - writer.write_line("Methods"); - writer.open_paren(); - let mut has_global_methods = false; - self.impl_items - .iter() - .flat_map(|(_, items)| items.iter()) - .for_each(|(impl_, v)| { - // only select trait methods are allowed - if let Some(trait_) = &impl_.trait_ { - if self - .config - .traits - .iter() - .any(|f| { - trait_.name == f.name - }) - { - // keep going - } else { - return; - } - }; - - let (decl, generics) = match &v.inner { - ItemEnum::Function(f) => (&f.decl, &f.generics), - _ => return, - }; - - let mut errors = Vec::default(); - - let mut inner_writer = PrettyWriter::new(); - - self.write_method_docstring(&v.id, &mut inner_writer, args); - - inner_writer.write_inline(v.name.as_ref().unwrap()); - inner_writer.write_inline("("); - let mut is_global_method = true; - decl.inputs - .iter() - .enumerate() - .for_each(|(i, (declaration_name, tp))| { - let arg_type: Result = tp.try_into(); - - if let Ok(arg_type) = arg_type { - // if the underlying ident is self, we shouldn't wrap it when printing it - // if type is unknown no wrapper exists - let wrapper_type: Option = ArgWrapperType::with_config(self.wrapped_type, &arg_type, config); - - match wrapper_type { - Some(w) => { - inner_writer.write_inline(&Arg::new(arg_type, w).to_string()) - } - None => { - inner_writer.write_inline(&format!("")); - errors.push(format!("Unsupported argument {}, not a wrapped type or primitive", arg_type)); - return; - } - }; - - if declaration_name != "self" && i + 1 != decl.inputs.len() { - inner_writer.write_inline(","); - } else if declaration_name == "self" { - is_global_method = false; - // macro needs to recognize the self receiver - inner_writer.write_inline(":"); - } - } else { - errors.push(format!("Unsupported argument, Not a simple type: {}.", arg_type.unwrap_err())) - }; - }); - - if is_global_method { - has_global_methods = true; - } - - inner_writer.write_inline(")"); - - if let Some(tp) = &decl.output{ - let arg_type: Result = tp.try_into(); - if let Ok(arg_type) = arg_type { - if let ArgType::Ref { .. } = arg_type { - errors.push("references are not supported as return types".to_owned()); - return; - } - - // if the underlying ident is self, we shouldn't wrap it when printing it - // if type is unknown, no wrapper type exists - let wrapper_type: Option = ArgWrapperType::with_config(self.wrapped_type, &arg_type, config); - - match wrapper_type { - Some(w) => { - inner_writer.write_inline(" -> "); - inner_writer.write_inline(&Arg::new(arg_type, w).to_string()); - } - None => { - errors.push(format!("Unsupported argument, not a wrapped type or primitive {arg_type}")); - inner_writer.write_inline(&format!("")); - } - } - } else { - errors.push(format!("Unsupported argument, not a simple type: {}", arg_type.unwrap_err())) - } - }; - - if !generics.params.is_empty() { - errors.push("Generics on the method".to_owned()); - } - - if !errors.is_empty() { - if args.print_errors { - writer.set_prefix("// ".into()); - writer.write_line(&format!("Exclusion reason: {}", errors.join(","))); - writer.extend(inner_writer); - writer.clear_prefix(); - writer.newline(); - } - } else { - used_method_identifiers.insert(v.name.as_deref().unwrap()); - inner_writer.write_inline(","); - writer.extend(inner_writer); - writer.newline(); - } - }); - - self.has_global_methods = has_global_methods; - writer.close_paren(); - - writer.write_line("+ Fields"); - writer.open_paren(); - - if let ItemEnum::Struct(struct_) = &self.item.inner { - if let StructKind::Plain { - fields, - fields_stripped: _, - } = &struct_.kind - { - fields - .iter() - .map(|field_| self.source.index.get(field_).unwrap()) - .filter_map(|field_| match &field_.inner { - ItemEnum::StructField(type_) => { - Some((field_.name.as_ref().unwrap(), type_, field_)) - } - _ => None, - }) - .filter_map(|(name, type_, field_)| { - let arg_type: ArgType = type_.try_into().ok()?; - let base_ident = arg_type - .base_ident() // resolve self - .unwrap_or(self.wrapped_type.as_str()); - - // if the underlying ident is self, we shouldn't wrap it when printing it - let wrapper: ArgWrapperType = arg_type - .is_self() - .then_some(ArgWrapperType::None) - .or_else(|| { - config - .primitives - .contains(base_ident) - .then_some(ArgWrapperType::Raw) - }) - .or_else(|| { - config - .types - .contains_key(base_ident) - .then_some(ArgWrapperType::Wrapped) - }) - // we allow this since we later resolve unknown types to be resolved as ReflectedValues - .unwrap_or(ArgWrapperType::None); - - let arg = Arg::new(arg_type, wrapper); - let mut reflectable_type = arg.to_string(); - - // if we do not have an appropriate wrapper and this is not a primitive or it's not public - // we need to go back to the reflection API - if arg.wrapper == ArgWrapperType::None { - if field_.attrs.iter().any(|attr| attr == "#[reflect(ignore)]") { - return None; - } - - reflectable_type = "Raw(ReflectedValue)".to_owned(); - } - - if let Some(docs) = &field_.docs { - writer.set_prefix("/// ".into()); - docs.lines().for_each(|line| { - writer.write_line(line); - }); - writer.clear_prefix(); - }; - - // add underscore if a method with same name exists - used_method_identifiers - .contains(name.as_str()) - .then(|| writer.write_line(&format!("#[rename(\"_{name}\")]"))); - writer.write_no_newline(name); - writer.write_inline(": "); - writer.write_inline(&reflectable_type); - writer.write_inline(","); - writer.newline(); - - Some(()) - }) - .for_each(drop); - } - }; - writer.close_paren(); - - static BINARY_OPS: [(&str, &str); 5] = [ - ("add", "Add"), - ("sub", "Sub"), - ("div", "Div"), - ("mul", "Mul"), - ("rem", "Rem"), - ]; - writer.write_line("+ BinOps"); - writer.open_paren(); - BINARY_OPS.into_iter().for_each(|(op, rep)| { - if let Some(items) = self.impl_items.get(op) { - items - .iter() - .filter_map(|(impl_, item)| Some((impl_, item, (&impl_.for_).try_into().ok()?))) - .filter(|(_, _, self_type): &(&&Impl, &&Item, ArgType)| { - let base_ident = - self_type.base_ident().unwrap_or(self.wrapped_type.as_str()); - let is_self_type_the_wrapper = (base_ident == self.wrapped_type) - && config.types.contains_key(base_ident); - let is_primitive = config.primitives.contains(base_ident); - is_self_type_the_wrapper || is_primitive - }) - .for_each(|(impl_, item, _self_type)| { - let _ = match &item.inner { - ItemEnum::Function(m) => { - m.decl - .inputs - .iter() - .map(|(_, t)| { - // check arg is valid - let arg_type: ArgType = t.try_into()?; - - // if the underlying ident is self, we shouldn't wrap it when printing it - let wrapper_type = ArgWrapperType::with_config( - self.wrapped_type, - &arg_type, - config, - ) - .unwrap(); - - Ok(Arg::new(arg_type, wrapper_type).to_string()) - }) - .collect::, _>>() - .map(|v| v.join(&format!(" {} ", rep))) - .and_then(|expr| { - // then provide return type - // for these traits that's on associated types within the impl - let out_type = impl_ - .items - .iter() - .find_map(|v| { - let item = self.source.index.get(v).unwrap(); - if let ItemEnum::AssocType { default, .. } = - &item.inner - { - if let Some("Output") = item.name.as_deref() { - return Some(default.as_ref().unwrap()); - } - } - None - }) - .ok_or_else(|| expr.clone())?; - - let arg_type: ArgType = out_type.try_into()?; - // if the underlying ident is self, we shouldn't wrap it when printing it - let wrapper_type: ArgWrapperType = - ArgWrapperType::with_config( - self.wrapped_type, - &arg_type, - config, - ) - .unwrap(); - - if wrapper_type == ArgWrapperType::None { - return Err(arg_type.to_string()); - } - - let return_string = - Arg::new(arg_type, wrapper_type).to_string(); - - writer.write_no_newline(&expr); - writer.write_inline(" -> "); - writer.write_inline(&return_string); - writer.write_inline(","); - writer.newline(); - Ok(()) - }) - } - _ => panic!("Expected method"), - }; - }) - } - }); - writer.close_paren(); - - static UNARY_OPS: [(&str, &str); 1] = [("neg", "Neg")]; - - writer.write_line("+ UnaryOps"); - writer.open_paren(); - UNARY_OPS.into_iter().for_each(|(op, rep)| { - if let Some(items) = self.impl_items.get(op) { - items.iter().for_each(|(_, _)| { - writer.write_line(&format!("{rep} self -> self")); - }); - } - }); - writer.close_paren(); - - self.config.derive_flags.iter().for_each(|flag| { - writer.write_inline("+ "); - flag.lines().for_each(|line| { - writer.write_line(line); - }); - }); - } + // /// Generates all derive flags for the type, + // /// + // /// Returns additional imports necessary for the generated methods + // /// + // /// ```rust,ignore + // /// my_type::Type : Value: + // /// ... // flags go here + // /// ``` + // pub fn write_derive_flags_body( + // &mut self, + // config: &Config, + // writer: &mut PrettyWriter, + // args: &Args, + // ) { + // if self.implemented_traits.contains("Clone") { + // // this flag requires cloning + // writer.write_line("Clone +"); + // } + + // if self.implemented_traits.contains("Debug") { + // // this flag requires cloning + // writer.write_line("Debug +"); + // } + + // let mut used_method_identifiers: HashSet<&str> = HashSet::default(); + + // writer.write_line("Methods"); + // writer.open_paren(); + // let mut has_global_methods = false; + // self.impl_items + // .iter() + // .flat_map(|(_, items)| items.iter()) + // .for_each(|(impl_, v)| { + // // only select trait methods are allowed + // if let Some(trait_) = &impl_.trait_ { + // if self + // .config + // .traits + // .iter() + // .any(|f| { + // trait_.name == f.name + // }) + // { + // // keep going + // } else { + // return; + // } + // }; + + // let (decl, generics) = match &v.inner { + // ItemEnum::Function(f) => (&f.decl, &f.generics), + // _ => return, + // }; + + // let mut errors = Vec::default(); + + // let mut inner_writer = PrettyWriter::new(); + + // self.write_method_docstring(&v.id, &mut inner_writer, args); + + // inner_writer.write_inline(v.name.as_ref().unwrap()); + // inner_writer.write_inline("("); + // let mut is_global_method = true; + // decl.inputs + // .iter() + // .enumerate() + // .for_each(|(i, (declaration_name, tp))| { + // let arg_type: Result = tp.try_into(); + + // if let Ok(arg_type) = arg_type { + // // if the underlying ident is self, we shouldn't wrap it when printing it + // // if type is unknown no wrapper exists + // let wrapper_type: Option = ArgWrapperType::with_config(self.wrapped_type, &arg_type, config); + + // match wrapper_type { + // Some(w) => { + // inner_writer.write_inline(&Arg::new(arg_type, w).to_string()) + // } + // None => { + // inner_writer.write_inline(&format!("")); + // errors.push(format!("Unsupported argument {}, not a wrapped type or primitive", arg_type)); + // return; + // } + // }; + + // if declaration_name != "self" && i + 1 != decl.inputs.len() { + // inner_writer.write_inline(","); + // } else if declaration_name == "self" { + // is_global_method = false; + // // macro needs to recognize the self receiver + // inner_writer.write_inline(":"); + // } + // } else { + // errors.push(format!("Unsupported argument, Not a simple type: {}.", arg_type.unwrap_err())) + // }; + // }); + + // if is_global_method { + // has_global_methods = true; + // } + + // inner_writer.write_inline(")"); + + // if let Some(tp) = &decl.output{ + // let arg_type: Result = tp.try_into(); + // if let Ok(arg_type) = arg_type { + // if let ArgType::Ref { .. } = arg_type { + // errors.push("references are not supported as return types".to_owned()); + // return; + // } + + // // if the underlying ident is self, we shouldn't wrap it when printing it + // // if type is unknown, no wrapper type exists + // let wrapper_type: Option = ArgWrapperType::with_config(self.wrapped_type, &arg_type, config); + + // match wrapper_type { + // Some(w) => { + // inner_writer.write_inline(" -> "); + // inner_writer.write_inline(&Arg::new(arg_type, w).to_string()); + // } + // None => { + // errors.push(format!("Unsupported argument, not a wrapped type or primitive {arg_type}")); + // inner_writer.write_inline(&format!("")); + // } + // } + // } else { + // errors.push(format!("Unsupported argument, not a simple type: {}", arg_type.unwrap_err())) + // } + // }; + + // if !generics.params.is_empty() { + // errors.push("Generics on the method".to_owned()); + // } + + // if !errors.is_empty() { + // if args.print_errors { + // writer.set_prefix("// ".into()); + // writer.write_line(&format!("Exclusion reason: {}", errors.join(","))); + // writer.extend(inner_writer); + // writer.clear_prefix(); + // writer.newline(); + // } + // } else { + // used_method_identifiers.insert(v.name.as_deref().unwrap()); + // inner_writer.write_inline(","); + // writer.extend(inner_writer); + // writer.newline(); + // } + // }); + + // self.has_global_methods = has_global_methods; + // writer.close_paren(); + + // writer.write_line("+ Fields"); + // writer.open_paren(); + + // if let ItemEnum::Struct(struct_) = &self.item.inner { + // if let StructKind::Plain { + // fields, + // fields_stripped: _, + // } = &struct_.kind + // { + // fields + // .iter() + // .map(|field_| self.source.index.get(field_).unwrap()) + // .filter_map(|field_| match &field_.inner { + // ItemEnum::StructField(type_) => { + // Some((field_.name.as_ref().unwrap(), type_, field_)) + // } + // _ => None, + // }) + // .filter_map(|(name, type_, field_)| { + // let arg_type: ArgType = type_.try_into().ok()?; + // let base_ident = arg_type + // .base_ident() // resolve self + // .unwrap_or(self.wrapped_type.as_str()); + + // // if the underlying ident is self, we shouldn't wrap it when printing it + // let wrapper: ArgWrapperType = arg_type + // .is_receiver() + // .then_some(ArgWrapperType::None) + // .or_else(|| { + // config + // .primitives + // .contains(base_ident) + // .then_some(ArgWrapperType::Raw) + // }) + // .or_else(|| { + // config + // .types + // .contains_key(base_ident) + // .then_some(ArgWrapperType::Wrapped) + // }) + // // we allow this since we later resolve unknown types to be resolved as ReflectedValues + // .unwrap_or(ArgWrapperType::None); + + // let arg = Arg::new(arg_type, wrapper); + // let mut reflectable_type = arg.to_string(); + + // // if we do not have an appropriate wrapper and this is not a primitive or it's not public + // // we need to go back to the reflection API + // if arg.wrapper == ArgWrapperType::None { + // if field_.attrs.iter().any(|attr| attr == "#[reflect(ignore)]") { + // return None; + // } + + // reflectable_type = "Raw(ReflectedValue)".to_owned(); + // } + + // if let Some(docs) = &field_.docs { + // writer.set_prefix("/// ".into()); + // docs.lines().for_each(|line| { + // writer.write_line(line); + // }); + // writer.clear_prefix(); + // }; + + // // add underscore if a method with same name exists + // used_method_identifiers + // .contains(name.as_str()) + // .then(|| writer.write_line(&format!("#[rename(\"_{name}\")]"))); + // writer.write_no_newline(name); + // writer.write_inline(": "); + // writer.write_inline(&reflectable_type); + // writer.write_inline(","); + // writer.newline(); + + // Some(()) + // }) + // .for_each(drop); + // } + // }; + // writer.close_paren(); + + // static BINARY_OPS: [(&str, &str); 5] = [ + // ("add", "Add"), + // ("sub", "Sub"), + // ("div", "Div"), + // ("mul", "Mul"), + // ("rem", "Rem"), + // ]; + // writer.write_line("+ BinOps"); + // writer.open_paren(); + // BINARY_OPS.into_iter().for_each(|(op, rep)| { + // if let Some(items) = self.impl_items.get(op) { + // items + // .iter() + // .filter_map(|(impl_, item)| Some((impl_, item, (&impl_.for_).try_into().ok()?))) + // .filter(|(_, _, self_type): &(&&Impl, &&Item, ArgType)| { + // let base_ident = + // self_type.base_ident().unwrap_or(self.wrapped_type.as_str()); + // let is_self_type_the_wrapper = (base_ident == self.wrapped_type) + // && config.types.contains_key(base_ident); + // let is_primitive = config.primitives.contains(base_ident); + // is_self_type_the_wrapper || is_primitive + // }) + // .for_each(|(impl_, item, _self_type)| { + // let _ = match &item.inner { + // ItemEnum::Function(m) => { + // m.decl + // .inputs + // .iter() + // .map(|(_, t)| { + // // check arg is valid + // let arg_type: ArgType = t.try_into()?; + + // // if the underlying ident is self, we shouldn't wrap it when printing it + // let wrapper_type = ArgWrapperType::with_config( + // self.wrapped_type, + // &arg_type, + // config, + // ) + // .unwrap(); + + // Ok(Arg::new(arg_type, wrapper_type).to_string()) + // }) + // .collect::, _>>() + // .map(|v| v.join(&format!(" {} ", rep))) + // .and_then(|expr| { + // // then provide return type + // // for these traits that's on associated types within the impl + // let out_type = impl_ + // .items + // .iter() + // .find_map(|v| { + // let item = self.source.index.get(v).unwrap(); + // if let ItemEnum::AssocType { default, .. } = + // &item.inner + // { + // if let Some("Output") = item.name.as_deref() { + // return Some(default.as_ref().unwrap()); + // } + // } + // None + // }) + // .ok_or_else(|| expr.clone())?; + + // let arg_type: ArgType = out_type.try_into()?; + // // if the underlying ident is self, we shouldn't wrap it when printing it + // let wrapper_type: ArgWrapperType = + // ArgWrapperType::with_config( + // self.wrapped_type, + // &arg_type, + // config, + // ) + // .unwrap(); + + // if wrapper_type == ArgWrapperType::None { + // return Err(arg_type.to_string()); + // } + + // let return_string = + // Arg::new(arg_type, wrapper_type).to_string(); + + // writer.write_no_newline(&expr); + // writer.write_inline(" -> "); + // writer.write_inline(&return_string); + // writer.write_inline(","); + // writer.newline(); + // Ok(()) + // }) + // } + // _ => panic!("Expected method"), + // }; + // }) + // } + // }); + // writer.close_paren(); + + // static UNARY_OPS: [(&str, &str); 1] = [("neg", "Neg")]; + + // writer.write_line("+ UnaryOps"); + // writer.open_paren(); + // UNARY_OPS.into_iter().for_each(|(op, rep)| { + // if let Some(items) = self.impl_items.get(op) { + // items.iter().for_each(|(_, _)| { + // writer.write_line(&format!("{rep} self -> self")); + // }); + // } + // }); + // writer.close_paren(); + + // self.config.derive_flags.iter().for_each(|flag| { + // writer.write_inline("+ "); + // flag.lines().for_each(|line| { + // writer.write_line(line); + // }); + // }); + // } } diff --git a/bevy_mod_scripting_common/Cargo.toml b/bevy_mod_scripting_common/Cargo.toml index 15bf3a5dde..b75f428a95 100644 --- a/bevy_mod_scripting_common/Cargo.toml +++ b/bevy_mod_scripting_common/Cargo.toml @@ -13,7 +13,7 @@ readme = "readme.md" [package.metadata.release] pre-release-replacements = [ - {file="Cargo.toml", search='^version\s*=\s*.*$', replace="version = \"{{version}}\"", exactly=1}, + { file = "Cargo.toml", search = '^version\s*=\s*.*$', replace = "version = \"{{version}}\"", exactly = 1 }, ] [lib] @@ -21,12 +21,18 @@ name = "bevy_mod_scripting_common" path = "src/lib.rs" [dependencies] +darling = "0.20.3" paste = "1.0.7" -syn = {version="1.0.57",features=["full","fold","extra-traits", "visit-mut"]} +syn = { version = "2.0.38", features = [ + "full", + "fold", + "extra-traits", + "visit-mut", +] } quote = "1.0.8" proc-macro2 = "1.0" convert_case = "0.5.0" serde = { version = "1.0", features = ["derive"] } serde_derive = "1.0.137" -indexmap = {version= "1.9.1", features= ["serde"]} +indexmap = { version = "1.9.1", features = ["serde"] } strum = { version = "0.24.1", features = ["derive"] } diff --git a/bevy_mod_scripting_common/src/arg.rs b/bevy_mod_scripting_common/src/arg.rs deleted file mode 100644 index 2591cba3d9..0000000000 --- a/bevy_mod_scripting_common/src/arg.rs +++ /dev/null @@ -1,262 +0,0 @@ -use std::{borrow::Cow, result}; - -use proc_macro2::TokenStream; -use quote::ToTokens; -use syn::{ - parenthesized, - parse::{Parse, ParseStream}, - token::Paren, - Ident, Token, -}; - -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] -pub enum SelfType { - Self_, - RefSelf, - MutSelf, -} - -impl SelfType { - /// converts this SelfType to a SimpleType given the value to substituted to self, preserves the references from self - pub fn resolve_as(self, as_: SimpleType) -> SimpleType { - match self { - SelfType::Self_ => SimpleType::BaseIdent(as_.base_ident().clone()), - SelfType::RefSelf => SimpleType::Ref { - ampersand: Some(Default::default()), - mut_: None, - type_: Box::new(as_), - }, - SelfType::MutSelf => SimpleType::Ref { - ampersand: Some(Default::default()), - mut_: Some(Default::default()), - type_: Box::new(as_), - }, - } - } - - /// Returns true if either a reference or mutable reference - pub fn is_any_ref(self) -> bool { - match self { - SelfType::Self_ => false, - SelfType::RefSelf => true, - SelfType::MutSelf => true, - } - } - - /// Returns true if mutable reference - pub fn is_mut_ref(self) -> bool { - match self { - SelfType::Self_ => false, - SelfType::RefSelf => false, - SelfType::MutSelf => true, - } - } -} - -impl Parse for SelfType { - fn parse(input: ParseStream) -> Result { - if input.peek(Token![&]) { - if input.peek2(Token![mut]) && input.peek3(Token![self]) { - input - .parse::() - .expect("Something went wrong parsing SelfType a "); - input - .parse::() - .expect("Something went wrong parsing SelfType b "); - input - .parse::() - .expect("Something went wrong parsing SelfType c"); - Ok(SelfType::MutSelf) - } else { - input - .parse::() - .expect("Something went wrong parsing SelfType d"); - input - .parse::() - .expect("Something went wrong parsing SelfType e"); - Ok(SelfType::RefSelf) - } - } else { - input.parse::()?; - Ok(SelfType::Self_) - } - } -} - -impl ToTokens for SelfType { - fn to_tokens(&self, tokens: &mut TokenStream) { - let tkns = match self { - SelfType::Self_ => quote::quote! {self}, - SelfType::RefSelf => quote::quote! {&self}, - SelfType::MutSelf => quote::quote! {&mut self}, - }; - - tokens.extend(tkns) - } -} - -#[derive(PartialEq, Eq, Hash, Debug, Clone)] -pub enum SimpleType { - BaseIdent(Ident), - Ref { - ampersand: Option, - mut_: Option, - type_: Box, - }, -} - -impl SimpleType { - /// Retrieves the base name of this simple type - pub fn base_ident(&self) -> &Ident { - match self { - SimpleType::BaseIdent(b) => b, - SimpleType::Ref { type_, .. } => type_.base_ident(), - } - } - - /// consumes self and produces the base ident - pub fn into_base_ident(self) -> Ident { - match self { - SimpleType::BaseIdent(b) => b, - SimpleType::Ref { type_, .. } => type_.into_base_ident(), - } - } - - pub fn mutate_base_ident(&mut self, mut f: F) { - match self { - SimpleType::BaseIdent(b) => f(b), - SimpleType::Ref { type_, .. } => type_.mutate_base_ident(f), - } - } - - /// Consumes self and produces a simple type without any outer references - /// e.g. `&MyType` -> `MyType` - pub fn strip_outer_refs(self) -> Self { - match self { - SimpleType::BaseIdent(_) => self, - SimpleType::Ref { type_, .. } => *type_, - } - } - - pub fn is_any_ref(&self) -> bool { - matches!(self, Self::Ref { .. }) - } - - pub fn is_mut_ref(&self) -> bool { - matches!(self, Self::Ref { mut_, .. } if mut_.is_some()) - } -} - -impl Parse for SimpleType { - fn parse(input: ParseStream) -> Result { - if input.peek(Token![&]) { - Ok(Self::Ref { - ampersand: input.parse().expect("Something went wrong"), - mut_: input.parse()?, - type_: input.parse()?, - }) - } else { - Ok(Self::BaseIdent(input.parse()?)) - } - } -} - -impl ToTokens for SimpleType { - fn to_tokens(&self, tokens: &mut TokenStream) { - match self { - SimpleType::BaseIdent(i) => tokens.extend(quote::quote!(#i)), - SimpleType::Ref { - ampersand, - mut_, - type_, - } => tokens.extend(quote::quote!(#ampersand #mut_ #type_)), - } - } -} - -#[derive(PartialEq, Eq, Hash, Debug)] -/// Raw argument expression argument received from the macro invocation -pub enum ArgType { - Raw { paren: Paren, type_: SimpleType }, - Wrapped { paren: Paren, type_: SimpleType }, - Self_(SelfType), -} - -#[allow(clippy::mixed_read_write_in_expression)] -impl Parse for ArgType { - fn parse(input: ParseStream) -> Result { - if input.peek(Ident) { - let ident: Ident = input.parse()?; - let f; - match ident.to_string().as_str() { - "Raw" => Ok(Self::Raw { paren: parenthesized!(f in input), type_: f.parse()? }), - "Wrapped" => Ok(Self::Wrapped { paren: parenthesized!(f in input), type_: f.parse()? }), - _ => panic!("Invalid argument, valid arguments are: [Raw(type),Wrapped(type),self,&self,&mut self]"), - } - } else { - Ok(Self::Self_(input.parse()?)) - } - } -} - -impl ToTokens for ArgType { - fn to_tokens(&self, tokens: &mut TokenStream) { - match self { - ArgType::Raw { type_, .. } => tokens.extend(quote::quote!(Raw(#type_))), - ArgType::Wrapped { type_, .. } => tokens.extend(quote::quote!(Wrapped(#type_))), - ArgType::Self_(s) => s.to_tokens(tokens), - }; - } -} - -impl ArgType { - /// retrieves the underlying argument type, if it's not a concrete type but a receiver, returns its type - pub fn type_(&self) -> result::Result<&SimpleType, SelfType> { - match self { - Self::Raw { type_, .. } | Self::Wrapped { type_, .. } => Ok(type_), - Self::Self_(s) => Err(*s), - } - } - - pub fn self_(&self) -> result::Result { - match self { - Self::Raw { type_, .. } | Self::Wrapped { type_, .. } => Err(type_), - Self::Self_(s) => Ok(*s), - } - } - - /// Retrieves the simple type or generates one using [`SelfType::resolve_as`](`SelfType`) if this is a self type - pub fn type_or_resolve SimpleType>(&self, mut f: F) -> Cow { - self.type_() - .map(Cow::Borrowed) - .unwrap_or_else(|self_| Cow::Owned(self_.resolve_as(f()))) - } - - pub fn is_any_ref(&self) -> bool { - match self { - ArgType::Raw { type_, .. } => type_.is_any_ref(), - ArgType::Wrapped { type_, .. } => type_.is_any_ref(), - ArgType::Self_(s) => s.is_any_ref(), - } - } - - pub fn is_mut_ref(&self) -> bool { - match self { - ArgType::Raw { type_, .. } => type_.is_mut_ref(), - ArgType::Wrapped { type_, .. } => type_.is_mut_ref(), - ArgType::Self_(s) => s.is_mut_ref(), - } - } - - pub fn is_wrapped(&self) -> bool { - matches!(self, Self::Wrapped { .. }) - } - - pub fn is_raw(&self) -> bool { - matches!(self, Self::Raw { .. }) - } - - pub fn is_self(&self) -> bool { - matches!(self, Self::Self_ { .. }) - } -} diff --git a/bevy_mod_scripting_common/src/derive_data.rs b/bevy_mod_scripting_common/src/derive_data.rs deleted file mode 100644 index 95953e8a39..0000000000 --- a/bevy_mod_scripting_common/src/derive_data.rs +++ /dev/null @@ -1,251 +0,0 @@ -use indexmap::IndexSet; - -use syn::{ - parenthesized, - parse::{Parse, ParseStream}, - punctuated::Punctuated, - token, Attribute, Block, DeriveInput, Field, Fields, Generics, Ident, Lit, LitStr, Meta, - MetaNameValue, Signature, Token, -}; - -pub const ATTRIBUTE_NAME: &str = "scripting"; - -pub enum ProxyData<'a> { - Struct(StructData<'a>), - TupleStruct(StructData<'a>), - UnitStruct(StructData<'a>), - Enum(EnumData<'a>), -} - -#[derive(Default, Debug)] -pub struct ProxyFlags { - flags: IndexSet, -} - -#[derive(Hash, Debug, PartialEq, Eq)] -pub enum ProxyFlag { - Debug, - Display, - Clone, - Fields, - Methods(Punctuated), - UnaryOps, - BinaryOps, -} - -#[derive(Hash, Debug, PartialEq, Eq)] -/// A representation of a proxied method, has the potential to define a full blown method as well, -/// it is up to each individual language to interpret the meaning of the attributes and method signatures. -/// -/// For example some function names may be reserved (`to_string` in lua for example) for operators. -pub struct ProxyMethod { - pub attrs: Vec, - pub sig: Signature, - pub body: Option, -} - -impl Parse for ProxyMethod { - fn parse(input: ParseStream) -> syn::Result { - Ok(Self { - attrs: input.call(Attribute::parse_outer)?, - sig: input.parse()?, - body: { - if input.peek(token::Brace) { - Some(input.parse()?) - } else { - None - } - }, - }) - } -} - -impl ProxyFlag { - pub fn from_ident_and_tokens( - ident: &Ident, - tokens: Option, - ) -> Result { - let name = ident.to_string(); - - let parse_ident_only = |f: fn() -> Self| { - if let Some(tokens) = &tokens { - let span = { - if tokens.is_empty() { - ident.span() - } else { - tokens.span() - } - }; - - Err(syn::Error::new( - span, - format!("'{name}' does not expect any arguments. Remove `({tokens})`"), - )) - } else { - Ok(f()) - } - }; - - let parse_with_body = |f: fn(ParseStream) -> Result| { - if let Some(tokens) = tokens { - f(tokens) - } else { - Err(syn::Error::new( - ident.span(), - format!("`{name}` expects arguments. Add `()`"), - )) - } - }; - - match name.as_str() { - "Clone" => parse_ident_only(|| Self::Clone), - "Debug" => parse_ident_only(|| Self::Debug), - "Methods" => parse_with_body(|input| { - Ok(Self::Methods(input.call(Punctuated::parse_terminated)?)) - }), - _ => Err(syn::Error::new_spanned(ident, "Unknown proxy flag")), - } - } -} - -pub struct ProxyMeta<'a> { - /// The name of the type being wrapped by this proxy - pub base_type_name: &'a Ident, - /// Flags representing additional required functionality - pub proxy_flags: ProxyFlags, - /// The generics defined on the base type - pub generics: &'a Generics, - /// type docstring - pub docstrings: Vec, -} - -pub struct StructData<'a> { - pub meta: ProxyMeta<'a>, - pub fields: Vec>, -} - -pub struct StructField<'a> { - pub data: &'a Field, - pub index: usize, -} - -pub struct EnumData<'a> { - pub meta: ProxyMeta<'a>, -} - -impl<'a> TryFrom<&'a DeriveInput> for ProxyData<'a> { - type Error = syn::Error; - - fn try_from(input: &'a DeriveInput) -> Result { - let flags = input - .attrs - .iter() - .filter_map(ProxyFlags::from_attribure) - .collect::, _>>()? - .into_iter() - .fold(ProxyFlags::default(), |mut a, b| { - a.merge(b); - a - }); - - let docstrings = input - .attrs - .iter() - .filter_map(|attr| { - if attr.path.is_ident("doc") { - match attr.parse_meta().unwrap() { - Meta::NameValue(MetaNameValue { - lit: Lit::Str(str), .. - }) => Some(str), - _ => unreachable!(), - } - } else { - None - } - }) - .collect::>(); - let meta = ProxyMeta { - base_type_name: &input.ident, - proxy_flags: flags, - generics: &input.generics, - docstrings, - }; - - match &input.data { - syn::Data::Struct(data) => { - let fields = Self::collect_struct_fields(&data.fields)?; - let struct_data = StructData { meta, fields }; - - match data.fields { - Fields::Named(..) => Ok(Self::Struct(struct_data)), - Fields::Unnamed(..) => Ok(Self::TupleStruct(struct_data)), - Fields::Unit => Ok(Self::UnitStruct(struct_data)), - } - } - syn::Data::Enum(_) => todo!(), - syn::Data::Union(_) => todo!(), - } - } -} - -impl ProxyData<'_> { - pub fn collect_struct_fields(fields: &Fields) -> Result, syn::Error> { - fields - .iter() - .enumerate() - .map(|(index, field)| Ok(StructField { data: field, index })) - .collect() - } -} - -impl ProxyFlags { - /// Parses a single proxy flag - pub fn parse_one(input: ParseStream) -> Result { - let attr_ident = input.parse::()?; - - // work out if there is a payload in the token - if input.peek(token::Paren) { - let tokens; - parenthesized!(tokens in input); - ProxyFlag::from_ident_and_tokens(&attr_ident, Some(&tokens)) - } else { - ProxyFlag::from_ident_and_tokens(&attr_ident, None) - } - } - - /// Parses proxy flags separated by the given separator - pub fn parse_separated( - input: ParseStream, - ) -> Result, syn::Error> { - Punctuated::<_, S>::parse_terminated_with(input, Self::parse_one) - } - - /// Parses a whole attribute with proxy flag annotations. Returns Some value if the attribute has a valid path, and None otherwise - pub fn from_attribure(attr: &Attribute) -> Option> { - if !attr.path.is_ident(ATTRIBUTE_NAME) { - return None; - } - - Some( - attr.parse_args_with(Self::parse_separated::) - .map(IntoIterator::into_iter) - .map(Iterator::collect), - ) - } - - pub fn contains(&self, flag: &ProxyFlag) -> bool { - self.flags.contains(flag) - } - - pub fn merge(&mut self, o: Self) { - self.flags.extend(o.flags.into_iter()) - } -} - -impl FromIterator for ProxyFlags { - fn from_iter>(iter: T) -> Self { - Self { - flags: FromIterator::from_iter(iter), - } - } -} diff --git a/bevy_mod_scripting_common/src/derive_flag.rs b/bevy_mod_scripting_common/src/derive_flag.rs deleted file mode 100644 index aaeb3721b0..0000000000 --- a/bevy_mod_scripting_common/src/derive_flag.rs +++ /dev/null @@ -1,202 +0,0 @@ -use proc_macro2::{Span, TokenStream}; -use syn::{ - parenthesized, - parse::{Parse, ParseStream}, - punctuated::Punctuated, - token::Paren, - Attribute, Ident, Member, Token, -}; - -use crate::{ops::*, utils::impl_parse_enum}; - -use quote::ToTokens; - -use super::arg::ArgType; - -impl_parse_enum!(input,ident: -#[derive(PartialEq,Eq,Hash)] -pub enum DeriveFlag { - - /// Tells the implementors this type supports `Debug` - Debug => {Ok(Self::Debug{ident})}, - /// Tells the implementors this type supports `Display` - Display => {Ok(Self::Display{ident})}, - /// Tells the implementors this type supports `Clone` - Clone{} => {Ok(Self::Clone{ident})}, - /// Tells the implementors what fields are available on this type - Fields { - paren: Paren, - fields: Punctuated - } => { - let f; - Ok(Self::Fields { - ident, - paren: parenthesized!(f in input), - fields: f.parse_terminated(AutoField::parse)? - }) - }, - /// Tells the implementors which methods are available on this type - Methods { - paren: Paren, - methods: Punctuated - } => { - let f; - Ok(Self::Methods{ - ident, - paren: parenthesized!(f in input), - methods: f.parse_terminated(AutoMethod::parse)? - }) - }, - /// Tells the implementors which unary operations this type supports - UnaryOps{ - paren : Paren, - ops: Punctuated - - } => { - let f; - Ok(Self::UnaryOps{ - ident, - paren: parenthesized!(f in input), - ops : f.parse_terminated(OpExpr::parse)? - }) - }, - /// Tells the implementors which binary operations this type supports - BinOps { - paren: Paren, - ops: Punctuated - } => { - let f; - Ok(Self::BinOps { - ident, - paren: parenthesized!(f in input), - ops: f.parse_terminated(OpExpr::parse)?, - }) - } -} -); - -#[derive(PartialEq, Eq, Hash)] -pub struct AutoMethod { - pub docstring: Vec, - pub ident: Ident, - pub paren: Paren, - pub self_: Option<(ArgType, Token![:])>, - pub args: Punctuated, - pub out: Option, -} - -impl ToTokens for AutoMethod { - fn to_tokens(&self, tokens: &mut TokenStream) { - let docstring = self.docstring.iter(); - let id = &self.ident; - let args = &self.args; - let self_ = self.self_.as_ref().map(|(a, _)| quote::quote!(#a:)); - let out = self.out.as_ref().map(|t| quote::quote! {-> #t}); - tokens.extend(quote::quote! { - #(#docstring)* - #id(#self_ #args) #out - }) - } -} - -#[allow(clippy::mixed_read_write_in_expression)] -impl Parse for AutoMethod { - fn parse(input: ParseStream) -> Result { - let f; - let o = Ok(Self { - docstring: Attribute::parse_outer(input)?, - ident: input.parse()?, - paren: parenthesized!(f in input), - self_: { - let parser = |p: ParseStream| { - Ok::<_, syn::Error>((p.parse::()?, p.parse::()?)) - }; - let fork = f.fork(); - if parser(&fork).is_ok() { - Some(parser(&f).expect("Something went wrong")) - } else { - None - } - }, - args: f.parse_terminated(ArgType::parse)?, - out: if input.peek(Token![->]) { - input.parse::]>()?; - Some(input.parse()?) - } else { - None - }, - }); - o - } -} - -#[derive(PartialEq, Eq, Hash)] -pub struct AutoFieldAttributes { - pub script_name: Option, -} - -impl TryFrom<&[Attribute]> for AutoFieldAttributes { - type Error = syn::Error; - - fn try_from(value: &[Attribute]) -> Result { - let mut out = Self { script_name: None }; - - for v in value { - let meta = v.parse_meta()?; - - if let Some(ident) = meta.path().get_ident() { - if *ident == "rename" { - if let syn::Meta::List(l) = &meta { - for nested in &l.nested { - if let syn::NestedMeta::Lit(syn::Lit::Str(s)) = nested { - out.script_name = Some(s.parse()?) - } - } - } - } - } - } - - Ok(out) - } -} - -#[derive(PartialEq, Eq, Hash)] -pub struct AutoField { - pub docstring: Vec, - pub attrs: Vec, - pub parsed_attrs: AutoFieldAttributes, - pub member: Member, - pub colon: Token![:], - pub type_: ArgType, -} - -impl Parse for AutoField { - fn parse(input: ParseStream) -> Result { - let attrs = Attribute::parse_outer(input)?; - let split_idx = attrs.partition_point(|attr| *attr.path.get_ident().unwrap() == "doc"); - Ok(Self { - docstring: attrs[0..split_idx].to_owned(), - attrs: attrs[split_idx..].to_owned(), - parsed_attrs: attrs[split_idx..].try_into()?, - member: input.parse()?, - colon: input.parse()?, - type_: input.parse()?, - }) - } -} - -impl ToTokens for AutoField { - fn to_tokens(&self, tokens: &mut TokenStream) { - let docstring = self.docstring.iter(); - let attrs = self.attrs.iter(); - let id = &self.member; - let type_ = &self.type_; - - tokens.extend(quote::quote! { - #(#docstring)* - #(#attrs)* - #id : #type_ - }) - } -} diff --git a/bevy_mod_scripting_common/src/implementor.rs b/bevy_mod_scripting_common/src/implementor.rs deleted file mode 100644 index 8c83675c28..0000000000 --- a/bevy_mod_scripting_common/src/implementor.rs +++ /dev/null @@ -1,75 +0,0 @@ -use proc_macro2::TokenStream; -use quote::{quote_spanned, ToTokens}; -use syn::{parse::Parse, spanned::Spanned, Result}; - -use crate::{derive_flag::DeriveFlag, newtype::Newtype}; - -/// A function on the wrapped type either wrapping an existing function or providing -/// additional functionality -pub trait WrapperFunction: Parse + ToTokens {} - -/// script-side API Implementation generator for a particular script language. -/// Helps avoid alot of boilerplate -pub trait WrapperImplementor: 'static { - type Function: WrapperFunction; - - fn module_name() -> &'static str; - - /// Generates the type definition for the given newtype - fn generate_newtype_definition(&mut self, new_type: &Newtype) -> Result; - - /// Generates the necessary trait implementations for the given newtype exposing the given functionality - fn generate_newtype_implementation<'a, I: Iterator>( - &mut self, - new_type: &'a Newtype, - functions: I, - ) -> Result; - - /// Generate methods from derive flags and newtype implementation blocks - fn generate_derive_flag_functions<'a, I: Iterator>( - &mut self, - new_type: &'a Newtype, - derive_flags: I, - ) -> Result>; - - /// Generate methods from newtype - fn generate_newtype_functions(&mut self, new_type: &Newtype) -> Result>; - - /// Turns newtype list into fully implemented wrapper types - fn generate(&mut self, new_type: Newtype) -> Result { - let definition = self.generate_newtype_definition(&new_type)?; - - let mut functions = - self.generate_derive_flag_functions(&new_type, new_type.args.flags.iter())?; - - functions.extend(self.generate_newtype_functions(&new_type)?); - - let implementation = self.generate_newtype_implementation(&new_type, functions.iter())?; - - Ok(quote_spanned! {new_type.span()=> - #definition - #implementation - }) - } - - // fn generate_all(&mut self, new_types: &NewtypeList) -> Result { - // let mut methods_so_far = IndexMap::default(); - - // let newtypes : TokenStream = new_types.new_types.iter().map(|v| { - // self.generate(v, &mut methods_so_far) - // }).collect::>()?; - - // let globals = self.generate_globals(new_types,methods_so_far)?; - // let module_name = format_ident!("{}",Self::module_name()); - // let header = &new_types.module_headers; - - // Ok(quote!{ - // #[allow(unused_parens,unreachable_patterns,unused_variables)] - // pub mod #module_name { - // #header - // #newtypes - // #globals - // } - // }) - // } -} diff --git a/bevy_mod_scripting_common/src/input.rs b/bevy_mod_scripting_common/src/input.rs index 95b75396ea..35a07292ba 100644 --- a/bevy_mod_scripting_common/src/input.rs +++ b/bevy_mod_scripting_common/src/input.rs @@ -1,124 +1,31 @@ +use darling::{util::Flag, FromDeriveInput, FromMeta}; +use proc_macro2::Ident; +use quote::{format_ident, ToTokens}; use std::{ - collections::{HashMap, VecDeque}, + collections::HashMap, + ops::{Deref, DerefMut}, str::FromStr, }; - -use indexmap::{IndexMap, IndexSet}; -use proc_macro2::{Ident, Span}; -use quote::{format_ident, ToTokens}; use strum::{Display, EnumString}; use syn::{ - parse::{Nothing, Parse}, + parse::Parse, punctuated::Punctuated, spanned::Spanned, - token::{And, Colon2, Gt, Lt, Mut}, + token::{And, Colon, Gt, Lt, Mut, PathSep}, visit_mut::VisitMut, - AngleBracketedGenericArguments, DataStruct, DeriveInput, Error, Fields, GenericArgument, Meta, - NestedMeta, PatType, PathArguments, PathSegment, Receiver, TraitItemMethod, Type, TypePath, - TypeReference, TypeTuple, + AngleBracketedGenericArguments, Attribute, Error, Expr, Field, Fields, GenericArgument, + PatType, Path, PathArguments, PathSegment, Receiver, Token, TraitItem, TraitItemFn, Type, + TypePath, TypeReference, TypeTuple, Variant, }; -use crate::utils::{attribute_to_string_lit, ident_to_type_path}; - -/// Convenience structure for holding data relevant to proxy generation -pub struct DeriveMeta {} - -#[derive(Debug)] -pub struct Language { - pub name: String, - pub on_feature: Option, -} - -/// Language settings for proxies -#[derive(Default, Debug)] -pub struct LanguageMeta { - pub languages: Vec, -} - -impl TryFrom for LanguageMeta { - type Error = syn::Error; - - fn try_from(list: syn::MetaList) -> Result { - let mut languages: Vec = Default::default(); - - for nested_meta in list.nested.into_iter() { - match nested_meta { - syn::NestedMeta::Lit(syn::Lit::Str(_str)) => { - let mut name = _str.value(); - let mut on_feature = None; - if let Some(postfix) = name.strip_prefix("on_feature(") { - if let Some(middle) = postfix.strip_suffix(')') { - name = middle.to_owned(); - on_feature = Some(name.clone()); - } - } - languages.push(Language { name, on_feature }) - } - _ => { - return Err(syn::Error::new_spanned( - nested_meta, - "Expected language name or wrapped language name", - )) - } - }; - } - - Ok(Self { languages }) - } -} +use crate::utils::ident_to_type_path; /// Flags which detail required functionality or additional derivation requirements -#[derive(Debug, Hash, PartialEq, Eq)] -pub enum DeriveFlag { - Debug, - Display, - Clone, -} - -impl TryFrom for DeriveFlag { - type Error = syn::Error; - - fn try_from(value: syn::NestedMeta) -> Result { - match value { - NestedMeta::Meta(Meta::Path(p)) if p.is_ident("Clone") => Ok(Self::Clone), - NestedMeta::Meta(Meta::Path(p)) if p.is_ident("Debug") => Ok(Self::Debug), - NestedMeta::Meta(Meta::Path(p)) if p.is_ident("Display") => Ok(Self::Display), - _ => Err(syn::Error::new_spanned( - value, - "Expected one of `Debug`, `Display`, `Clone`", - )), - } - } -} - -/// Container for proxy flags -#[derive(Debug, Default)] +#[derive(Debug, FromMeta)] pub struct ProxyFlags { - pub flags: IndexSet, -} - -impl TryFrom for ProxyFlags { - type Error = syn::Error; - - fn try_from(meta_list: syn::MetaList) -> Result { - let mut derive_flags: IndexSet = Default::default(); - - for nested_meta in meta_list.nested { - let span = nested_meta.span(); - let flag: DeriveFlag = nested_meta.try_into()?; - if derive_flags.contains(&flag) { - return Err(syn::Error::new( - span, - "This flag was already defined, remove duplicate flag", - )); - } else { - derive_flags.insert(flag); - } - } - Ok(Self { - flags: derive_flags, - }) - } + pub debug: Flag, + pub display: Flag, + pub clone: Flag, } pub(crate) struct ZeroOrManyTerminated(Punctuated); @@ -159,7 +66,7 @@ pub enum ProxyData { pub struct UnitPath { pub std_type_ident: Option, pub ident: Ident, - pub colon2_token: Option, + pub colon2_token: Option, pub lt_token: Lt, pub gt_token: Gt, pub inner: Box, @@ -170,7 +77,7 @@ pub struct UnitPath { pub struct DuoPath { pub std_type_ident: Option, pub ident: Ident, - pub colon2_token: Option, + pub colon2_token: Option, pub lt_token: Lt, pub gt_token: Gt, pub left: Box, @@ -189,7 +96,7 @@ pub struct Reference { /// Stores both the proxied and proxy identifier i.e. `T` and `LuaT` #[derive(Debug, Clone)] pub struct ProxyType { - pub proxied_ident: Ident, + pub proxied_path: Path, pub proxy_ident: Ident, } @@ -222,7 +129,7 @@ impl SimpleType { pub fn new_from_fn_arg( proxy_prefix: &'static str, arg: &syn::FnArg, - proxied_type_identifier: &Ident, + proxied_type_path: &Path, proxied_to_proxy_ident_map: &HashMap>, ) -> Result { match arg { @@ -235,8 +142,11 @@ impl SimpleType { let mutability = mutability.as_ref().copied(); let inner = Box::new(SimpleType::new_from_contextual_type( proxy_prefix, - &Type::Path(ident_to_type_path(proxied_type_identifier.clone())), - proxied_type_identifier, + &Type::Path(TypePath { + qself: None, + path: proxied_type_path.clone(), + }), + proxied_type_path, proxied_to_proxy_ident_map, )?); Ok(Self::Reference(Reference { @@ -247,15 +157,18 @@ impl SimpleType { } None => Self::new_from_contextual_type( proxy_prefix, - &Type::Path(ident_to_type_path(proxied_type_identifier.clone())), - proxied_type_identifier, + &Type::Path(TypePath { + qself: None, + path: proxied_type_path.clone(), + }), + proxied_type_path, proxied_to_proxy_ident_map, ), }, syn::FnArg::Typed(PatType { ty, .. }) => Self::new_from_contextual_type( proxy_prefix, ty.as_ref(), - proxied_type_identifier, + proxied_type_path, proxied_to_proxy_ident_map, ), } @@ -268,7 +181,13 @@ impl SimpleType { proxied_type: &Type, proxied_to_proxy_ident_map: &HashMap>, ) -> Result { - Self::new_from_type(proxy_prefix, proxied_type, None, proxied_to_proxy_ident_map) + Self::new_from_type( + proxy_prefix, + proxied_type, + None, + proxied_to_proxy_ident_map, + false, + ) } /// Constructs a new SimpleProxyType from a `syn::Type`, contextual receivers such as `Self` and `self` will be replaced @@ -276,14 +195,32 @@ impl SimpleType { pub fn new_from_contextual_type( proxy_prefix: &'static str, proxied_type: &Type, - proxied_type_identifier: &Ident, + proxied_type_path: &Path, proxied_to_proxy_ident_map: &HashMap>, ) -> Result { Self::new_from_type( proxy_prefix, proxied_type, - Some(proxied_type_identifier), + Some(proxied_type_path), proxied_to_proxy_ident_map, + false, + ) + } + + /// Constructs a new SimpleProxyType from a `syn::Type`, contextual receivers such as `Self` and `self` will be replaced + /// with the given identifier prefixed with the proxy_prefix + /// All types will be proxied with the given proxy prefix + pub fn new_from_contextual_type_proxy_all( + proxy_prefix: &'static str, + proxied_type: &Type, + proxied_type_path: &Path, + ) -> Result { + Self::new_from_type( + proxy_prefix, + proxied_type, + Some(proxied_type_path), + &Default::default(), + true, ) } @@ -293,58 +230,66 @@ impl SimpleType { /// - If it's not in the map it's built as a SimpleType::Type fn new_proxied_type_or_type( proxy_prefix: &'static str, - proxied_ident: &Ident, + proxied_path: Path, proxied_to_proxy_ident_map: &HashMap>, + proxy_prefix_all: bool, ) -> SimpleType { - if let Some((original_ident, replacement_ident)) = - proxied_to_proxy_ident_map.get_key_value(proxied_ident) - { + let last_segment = &proxied_path.segments.last().unwrap().ident; + let replacement_ident = proxied_to_proxy_ident_map.get(last_segment); + + if proxy_prefix_all || replacement_ident.is_some() { let proxy_ident = replacement_ident - .as_ref() - .unwrap_or(&format_ident!("{proxy_prefix}{original_ident}")) - .clone(); + .cloned() + .flatten() + .unwrap_or_else(|| format_ident!("{proxy_prefix}{}", last_segment)); SimpleType::ProxyType(ProxyType { - proxied_ident: original_ident.clone(), + proxied_path, proxy_ident, }) } else { - Self::Type(syn::Type::Path(ident_to_type_path(proxied_ident.clone()))) + Self::Type(syn::Type::Path(TypePath { + qself: None, + path: proxied_path.clone(), + })) } } /// Constructs a new SimpleProxyType from a `syn::Type`, if `proxied_type_identifier` is given then contextual /// receivers such as `Self` and `self` will be replaced with the given identifier prefixed with the proxy_prefix, otherwise an error will be returned. - /// types with base identifiers not in the proxied_to_proxy_ident_map list are treated as non-proxy types and will be wrapped in a SimpleProxyType::Type + /// types with base identifiers not in the proxied_to_proxy_ident_map list are treated as non-proxy types and will be wrapped in a SimpleProxyType::Type. + /// If the proxy_prefix_all option is passed, the ident map will be ignored and EVERY type inside will be treated as a default proxy (prefixed with the proxy prefix as well) fn new_from_type( proxy_prefix: &'static str, proxied_type: &Type, - proxied_type_identifier: Option<&Ident>, + proxied_type_path: Option<&Path>, proxied_to_proxy_ident_map: &HashMap>, + proxy_prefix_all: bool, ) -> Result { match proxied_type { Type::Path(p) if p.path.is_ident("self") || p.path.is_ident("Self") => { - let proxied_ident: &Ident = proxied_type_identifier.ok_or_else(|| { + let proxied_path: &Path = proxied_type_path.ok_or_else(|| { Error::new_spanned( proxied_type, "Did not expect contextual receiver in constructing simple proxy type" .to_owned(), ) })?; - Ok(Self::new_proxied_type_or_type(proxy_prefix, proxied_ident, proxied_to_proxy_ident_map)) + Ok(Self::new_proxied_type_or_type(proxy_prefix, proxied_path.clone(), proxied_to_proxy_ident_map, proxy_prefix_all)) } Type::Path(p) if !p.path.segments.is_empty() => { let last_segment = p.path.segments.last().unwrap(); if last_segment.arguments.is_empty() { - return Ok(Self::new_proxied_type_or_type(proxy_prefix,&last_segment.ident, proxied_to_proxy_ident_map)); + return Ok(Self::new_proxied_type_or_type(proxy_prefix, p.path.clone(), proxied_to_proxy_ident_map, proxy_prefix_all)); } else if let PathArguments::AngleBracketed(args) = &last_segment.arguments { if args.args.len() == 1 { if let GenericArgument::Type(arg_type) = args.args.first().unwrap() { let inner = Box::new(Self::new_from_type( proxy_prefix, arg_type, - proxied_type_identifier, - proxied_to_proxy_ident_map + proxied_type_path, + proxied_to_proxy_ident_map, + proxy_prefix_all )?); return Ok(SimpleType::UnitPath(UnitPath { std_type_ident: StdTypeIdent::from_str(&last_segment.ident.to_string()).ok(), @@ -363,14 +308,16 @@ impl SimpleType { let left = Box::new(Self::new_from_type( proxy_prefix, left, - proxied_type_identifier, - proxied_to_proxy_ident_map + proxied_type_path, + proxied_to_proxy_ident_map, + proxy_prefix_all )?); let right = Box::new(Self::new_from_type( proxy_prefix, right, - proxied_type_identifier, - proxied_to_proxy_ident_map + proxied_type_path, + proxied_to_proxy_ident_map, + proxy_prefix_all )?); return Ok(SimpleType::DuoPath(DuoPath { std_type_ident: StdTypeIdent::from_str(&last_segment.ident.to_string()).ok(), @@ -392,8 +339,9 @@ impl SimpleType { inner: Box::new(Self::new_from_type( proxy_prefix, &tr.elem, - proxied_type_identifier, - proxied_to_proxy_ident_map + proxied_type_path, + proxied_to_proxy_ident_map, + proxy_prefix_all )?), })), Type::Infer(_) => Ok(SimpleType::Type(proxied_type.clone())), @@ -551,7 +499,10 @@ impl VisitSimpleType for TypeConstructorVisitor { if self.generate_proxy_type { Type::Path(ident_to_type_path(proxy_type.proxy_ident.clone())) } else { - Type::Path(ident_to_type_path(proxy_type.proxied_ident.clone())) + Type::Path(TypePath { + qself: None, + path: proxy_type.proxied_path.clone(), + }) } } @@ -574,140 +525,61 @@ impl VisitSimpleType for TypeConstructorVisitor { } } -/// Attributes relating to the proxy as a whole -#[derive(Debug)] -pub struct ProxyMeta { - /// the identifier of the proxied type - pub proxied_name: Ident, - /// the identifier for the proxy type +#[derive(FromDeriveInput)] +#[darling(attributes(proxy), forward_attrs(allow, doc, cfg))] +pub struct ProxyInput { + /// The name of the type for which we are generating a proxy + pub ident: syn::Ident, + pub attrs: Vec, + + pub remote: Option, + /// The name to use for the proxy type, if not provided the language derive macro + /// will generate one using a standard prefix. + #[darling(rename = "name")] pub proxy_name: Option, - /// language derivation settings - pub language_meta: LanguageMeta, - /// additional flags for the proxy - pub proxy_flags: ProxyFlags, - /// functions to be proxied - pub functions: IndexMap, - /// the inner type data - pub data: ProxyData, - /// the derive input span - pub span: Span, - /// docstrings - pub docstrings: Vec, + + /// The body of the type for which we are generating a proxy + pub data: darling::ast::Data, + + /// Flags signifying which additional trait implementation should be generated on the proxy type + pub derive: ProxyFlags, + + /// A list of multi-lang function definitions to be generated on the proxy type + pub functions: TraitItemFnsWrapper, } -impl TryFrom for ProxyMeta { - type Error = syn::Error; - - fn try_from(derive_input: DeriveInput) -> Result { - let mut proxy_name = None; - let span = derive_input.span(); - - // helper for collecting errors which are not fatal to the logic flow - // simplifies logical flow - let mut accumulated_errors = VecDeque::::default(); - - let docstrings = derive_input - .attrs - .iter() - .filter(|attr| attr.path.is_ident("doc")) - .map(attribute_to_string_lit) - .filter(|s| !s.is_empty()) - .collect(); - - let proxy_meta = derive_input - .attrs - .iter() - .find(|attr| attr.path.is_ident("proxy")) - .ok_or_else(|| syn::Error::new_spanned(&derive_input, "`proxy` meta missing")) - .and_then(|attr| attr.parse_meta())?; - - let functions = derive_input - .attrs - .into_iter() - .find(|attr| attr.path.is_ident("functions")) - .map_or(Ok(IndexMap::default()), |attr| { - attr.parse_args::>() - .map(|fns| { - let mut fn_map = IndexMap::default(); - fns.0 - .into_iter() - .map(|_fn| (_fn.sig.ident.clone(), _fn)) - .for_each(|(name, body)| { - if let Some(old_val) = fn_map.insert(name, body) { - accumulated_errors.push_back(syn::Error::new_spanned( - old_val.sig.ident, // old == new ident - "duplicate Lua proxy function, re-name this function", - )) - } - }); - fn_map - }) - })?; - - let mut language_meta = Default::default(); - let mut proxy_flags: ProxyFlags = Default::default(); - - if let syn::Meta::List(list) = proxy_meta { - for attr in list.nested.into_iter() { - match attr { - NestedMeta::Meta(Meta::NameValue(pair)) => { - let ident = pair.path.get_ident().ok_or_else(|| { - syn::Error::new_spanned(&pair, "Keys must be identifiers") - })?; - - match (ident.to_string().as_str(), pair.lit) { - ("name", syn::Lit::Str(_str)) => { - proxy_name = Some(Ident::new(&_str.value(), _str.span())) - } - _ => { - return Err(syn::Error::new_spanned(ident, "Unrecognized argument")) - } - } - } - NestedMeta::Meta(Meta::List(list)) => { - let ident = list - .path - .get_ident() - .ok_or_else(|| syn::Error::new_spanned(&list, "Expected identifier"))?; - - match ident.to_string().as_str() { - "languages" => language_meta = list.try_into()?, - "derive" => proxy_flags = list.try_into()?, - _ => return Err(syn::Error::new_spanned(list, "")), - } - } - _ => return Err(syn::Error::new_spanned(attr, "Expected key value pair")), - } - } - } else { - return Err(syn::Error::new_spanned( - proxy_meta, - "Expected list of key value pairs", - )); - } +pub struct TraitItemFnsWrapper(pub Vec); - let data = match derive_input.data { - syn::Data::Struct(DataStruct { fields, .. }) => ProxyData::Struct { fields }, - syn::Data::Enum(_) => todo!(), - syn::Data::Union(_) => todo!(), - }; +impl FromMeta for TraitItemFnsWrapper { + fn from_string(value: &str) -> darling::Result { + let token_stream: proc_macro2::TokenStream = value.parse().map_err(syn::Error::from)?; + let trait_items_vec = vec![syn::parse2(token_stream)?]; + Ok(TraitItemFnsWrapper(trait_items_vec)) + } - let proxied_name = derive_input.ident; + fn from_list(items: &[darling::ast::NestedMeta]) -> darling::Result { + Ok(TraitItemFnsWrapper( + items + .iter() + .map(Self::from_nested_meta) + .collect::, _>>()? + .into_iter() + .flat_map(|v| v.0.into_iter()) + .collect::>(), + )) + } +} - if let Some(first_err) = accumulated_errors.pop_front() { - return Err(first_err); - } +impl Deref for TraitItemFnsWrapper { + type Target = Vec; - Ok(ProxyMeta { - proxied_name, - proxy_name, - proxy_flags, - language_meta, - functions, - data, - span, - docstrings, - }) + fn deref(&self) -> &Self::Target { + &self.0 + } +} +impl DerefMut for TraitItemFnsWrapper { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 } } @@ -749,7 +621,7 @@ mod test { assert!(!visitor.visit(&super::SimpleType::Unit)); assert!( !visitor.visit(&super::SimpleType::ProxyType(super::ProxyType { - proxied_ident: syn::Ident::new("T", proc_macro2::Span::call_site()), + proxied_path: syn::Ident::new("T", proc_macro2::Span::call_site()).into(), proxy_ident: syn::Ident::new("LuaT", proc_macro2::Span::call_site()), })) ); @@ -771,7 +643,7 @@ mod test { and_token: syn::Token![&](proc_macro2::Span::call_site()), mutability: None, inner: Box::new(super::SimpleType::ProxyType(super::ProxyType { - proxied_ident: syn::Ident::new("T", proc_macro2::Span::call_site()), + proxied_path: syn::Ident::new("T", proc_macro2::Span::call_site()).into(), proxy_ident: syn::Ident::new("LuaT", proc_macro2::Span::call_site()), })), })) diff --git a/bevy_mod_scripting_common/src/lib.rs b/bevy_mod_scripting_common/src/lib.rs index d4dcff44b4..5d7b01f967 100644 --- a/bevy_mod_scripting_common/src/lib.rs +++ b/bevy_mod_scripting_common/src/lib.rs @@ -1,8 +1,2 @@ -pub mod arg; -pub mod derive_data; -pub mod derive_flag; -pub mod implementor; pub mod input; -pub mod newtype; -pub mod ops; pub mod utils; diff --git a/bevy_mod_scripting_common/src/newtype.rs b/bevy_mod_scripting_common/src/newtype.rs deleted file mode 100644 index 3e1d76b4d4..0000000000 --- a/bevy_mod_scripting_common/src/newtype.rs +++ /dev/null @@ -1,177 +0,0 @@ -use std::collections::HashSet; - -use indexmap::IndexSet; -use proc_macro2::TokenStream; -use syn::{ - braced, - parse::{Parse, ParseStream}, - punctuated::*, - spanned::Spanned, - token::*, - Attribute, Ident, Token, TypePath, -}; - -use crate::{derive_flag::DeriveFlag, utils::EmptyToken}; -use quote::ToTokens; - -pub struct NewtypeArgs { - pub docstring: Vec, - pub base_type: TypePath, - pub type_colon: Token![:], - pub base_type_ident: Ident, - pub wrapper_type: Ident, - pub flags: IndexSet, -} - -impl NewtypeArgs { - /// Verify the given derive flags - pub fn verify(self) -> Result { - let mut fields = None; - let mut methods = None; - - self.flags.iter().for_each(|f| match f { - DeriveFlag::Fields { .. } => fields = Some(f), - DeriveFlag::Methods { .. } => methods = Some(f), - _ => {} - }); - - let mut seen_identifiers: HashSet<&Ident> = HashSet::default(); - // verify there aren't any name clashes - if let ( - Some(DeriveFlag::Fields { fields, .. }), - Some(DeriveFlag::Methods { methods, .. }), - ) = (fields, methods) - { - for m in methods { - if seen_identifiers.contains(&m.ident) { - return Err(syn::Error::new_spanned( - m, - format!( - "Method name `{}` clashes with another field or method", - &m.ident - ), - )); - } - seen_identifiers.insert(&m.ident); - } - - for f in fields { - match &f.member { - syn::Member::Named(n) => { - let contains = if let Some(v) = &f.parsed_attrs.script_name { - seen_identifiers.contains(v) - } else { - seen_identifiers.contains(n) - }; - if contains { - return Err(syn::Error::new_spanned( - n, - format!("Field name `{}` clashes with another field or method, use #[rename(\"new_name\")] to rename the field on script side", n), - )); - } - seen_identifiers.insert(n); - } - syn::Member::Unnamed(_) => {} - } - } - } - - Ok(self) - } -} - -impl ToTokens for NewtypeArgs { - fn to_tokens(&self, tokens: &mut TokenStream) { - let docstrings = self.docstring.iter(); - let base_type = &self.base_type; - let flags = self.flags.iter(); - tokens.extend(quote::quote! { - #(#docstrings)* - #base_type : #(#flags)+* - }) - } -} - -impl Parse for NewtypeArgs { - fn parse(input: ParseStream) -> Result { - let docstring = Attribute::parse_outer(input)?; - let base_type: TypePath = input.parse()?; - let short_base_type: String = base_type - .path - .segments - .last() - .ok_or_else(|| input.error("Path does not have identifier"))? - .ident - .to_string(); - let short_wrapper_type: String = format!("Lua{}", short_base_type); - let sbt_ident = Ident::new(&short_base_type, base_type.span()); - let swt_ident = Ident::new(&short_wrapper_type, base_type.span()); - let out = Self { - docstring, - wrapper_type: swt_ident, - base_type_ident: sbt_ident, - base_type, - type_colon: input.parse()?, - flags: Punctuated::::parse_separated_nonempty(input)? - .into_iter() - .collect::>(), - }; - out.verify() - } -} - -pub struct WrapperFunctionList { - pub label: Ident, - pub impl_: Token![impl], - pub braces: Brace, - pub functions: TokenStream, -} - -impl ToTokens for WrapperFunctionList { - fn to_tokens(&self, tokens: &mut TokenStream) { - let ident = &self.label; - let functions = &self.functions; - tokens.extend(quote::quote! { - #ident impl { - #functions - } - }) - } -} - -#[allow(clippy::mixed_read_write_in_expression)] -impl Parse for WrapperFunctionList { - fn parse(input: ParseStream) -> Result { - let f; - Ok(Self { - label: input.parse()?, - impl_: input.parse()?, - braces: braced!(f in input), - functions: f.parse()?, - }) - } -} - -pub struct Newtype { - pub args: NewtypeArgs, - pub impl_blocks: Punctuated, -} - -impl ToTokens for Newtype { - fn to_tokens(&self, tokens: &mut TokenStream) { - let args = &self.args; - let functions = &self.impl_blocks; - tokens.extend(quote::quote!( - {#args #functions} - )) - } -} - -impl Parse for Newtype { - fn parse(input: ParseStream) -> Result { - Ok(Self { - args: input.parse()?, - impl_blocks: Punctuated::parse_terminated(input)?, - }) - } -} diff --git a/bevy_mod_scripting_common/src/ops.rs b/bevy_mod_scripting_common/src/ops.rs deleted file mode 100644 index cc974af880..0000000000 --- a/bevy_mod_scripting_common/src/ops.rs +++ /dev/null @@ -1,160 +0,0 @@ -use proc_macro2::{Span, TokenStream}; -use quote::{quote_spanned, ToTokens}; -use syn::{ - parse::{Parse, ParseStream}, - Token, -}; - -use crate::utils::impl_parse_enum; - -use super::arg::ArgType; - -impl_parse_enum!(input,ident: -#[derive(PartialEq,Eq,Hash,Clone,Debug)] -pub enum OpName { - Add => {Ok(Self::Add{ident})}, - Sub => {Ok(Self::Sub{ident})}, - Mul => {Ok(Self::Mul{ident})}, - Div => {Ok(Self::Div{ident})}, - Rem => {Ok(Self::Rem{ident})}, - Neg => {Ok(Self::Neg{ident})}, - -} - -impl MathOpName { - pub fn to_rlua_metamethod_path(&self) -> TokenStream { - match self { - OpName::Add { ident } => quote_spanned!(ident.span()=> Add), - OpName::Sub { ident } => quote_spanned!(ident.span()=> Sub), - OpName::Mul { ident } => quote_spanned!(ident.span()=> Mul), - OpName::Div { ident } => quote_spanned!(ident.span()=> Div), - OpName::Rem { ident } => quote_spanned!(ident.span()=> Mod), - OpName::Neg { ident } => quote_spanned!(ident.span()=> Unm), - - } - } - - pub fn to_rust_method_ident(&self) -> TokenStream { - match self { - Self::Add{ident} => quote_spanned!{ident.span()=> add}, - Self::Sub{ident} => quote_spanned!{ident.span()=> sub}, - Self::Mul{ident} => quote_spanned!{ident.span()=> mul}, - Self::Div{ident} => quote_spanned!{ident.span()=> div}, - Self::Rem{ident} => quote_spanned!{ident.span()=> rem}, - Self::Neg{ident} => quote_spanned!{ident.span()=> neg}, - - } - } -} -); - -/// Left or Right -#[derive(Clone, Copy, PartialEq, Eq)] -pub enum Side { - Left, - Right, -} - -use std::fmt; -impl fmt::Display for Side { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Side::Left => f.write_str("Left"), - Side::Right => f.write_str("Right"), - } - } -} - -impl Side { - pub fn opposite(&self) -> Self { - match self { - Side::Left => Self::Right, - Side::Right => Self::Left, - } - } -} - -/// Represents either a unary or binary expression, where at least one side has the receiver (self) type -#[derive(PartialEq, Eq, Hash, Debug)] -pub struct OpExpr { - pub left: Option, - pub op: OpName, - pub right: ArgType, - pub arrow: Token![->], - pub return_type: ArgType, -} - -impl Parse for OpExpr { - fn parse(input: ParseStream) -> Result { - let s = Self { - left: (input.fork()) - .parse::() - .is_err() - .then(|| Ok::<_, syn::Error>(Some(input.parse()?))) - .unwrap_or(Ok(None))?, - op: input.parse()?, - right: input.parse()?, - arrow: input.parse()?, - return_type: input.parse()?, - }; - - if s.has_receiver() { - Ok(s) - } else { - Err(syn::Error::new_spanned(s, "Invalid expression, binary/unary expressions expect at least one side to be one of: [self,&self,&mut self]")) - } - } -} - -impl ToTokens for OpExpr { - fn to_tokens(&self, tokens: &mut TokenStream) { - let left = &self.left; - let op = &self.op; - let right = &self.right; - let return_type = &self.return_type; - - tokens.extend(quote::quote! { - #left #op #right -> #return_type - }) - } -} - -impl OpExpr { - pub fn is_binary(&self) -> bool { - self.left.is_some() - } - - fn has_receiver(&self) -> bool { - if let Some(ArgType::Self_(_)) = self.left { - true - } else if let ArgType::Self_(_) = self.right { - true - } else { - true - } - } - - pub fn has_receiver_on_side(&self, side: Side) -> bool { - match side { - Side::Left => self.left.as_ref().map(|t| t.is_self()).unwrap_or_default(), - Side::Right => self.right.is_self(), - } - } - - /// Maps the given side if it exists (right is guaranteed to exist, left is not) - pub fn map_side O>(&self, side: Side, f: F) -> Option { - match side { - Side::Left => self.left.as_ref().map(f), - Side::Right => Some(f(&self.right)), - } - } - - /// call map_side on both Left and Right sides and return the results as a tuple - pub fn map_both O>(&self, mut f: F) -> (Option, O) { - ( - self.map_side(Side::Left, |a| f(a, Side::Left)), - self.map_side(Side::Right, |a| f(a, Side::Right)) - .expect("Cannot happen"), - ) - } -} diff --git a/bevy_mod_scripting_common/src/utils.rs b/bevy_mod_scripting_common/src/utils.rs index 3ef2a7ea22..df7acf2e4d 100644 --- a/bevy_mod_scripting_common/src/utils.rs +++ b/bevy_mod_scripting_common/src/utils.rs @@ -104,8 +104,12 @@ use syn::{ Attribute, Path, PathArguments, PathSegment, Type, TypePath, }; -pub fn attribute_to_string_lit(attrs: &Attribute) -> TokenStream { - attrs.tokens.clone().into_iter().skip(1).collect() +pub fn doc_attribute_to_string_lit(attrs: &Attribute) -> Option { + attrs + .meta + .require_name_value() + .map(|v| v.value.to_token_stream()) + .ok() } pub fn ident_to_type_path(ident: Ident) -> TypePath { diff --git a/bevy_mod_scripting_derive/src/lib.rs b/bevy_mod_scripting_derive/src/lib.rs index ade12a2cc4..e3224fe1f5 100644 --- a/bevy_mod_scripting_derive/src/lib.rs +++ b/bevy_mod_scripting_derive/src/lib.rs @@ -1,40 +1,9 @@ #![allow(dead_code, unused_variables, unused_features)] -use bevy_mod_scripting_common::input::ProxyMeta; use proc_macro::TokenStream; -use quote::{format_ident, quote, quote_spanned, ToTokens}; +use quote::{format_ident, quote_spanned, ToTokens}; use syn::{parse::Parse, parse_macro_input, spanned::Spanned, Attribute, DeriveInput}; -#[proc_macro_derive(ScriptProxy, attributes(functions, proxy, rhai, lua))] -pub fn make_script_proxy(input: TokenStream) -> TokenStream { - let original_tokens: proc_macro2::TokenStream = input.clone().into(); - let derive_input = parse_macro_input!(input as DeriveInput); - - let attrs: Result = derive_input.try_into(); - - match attrs { - Ok(attrs) => { - let mut tokens: Vec = Default::default(); - for lang in attrs.language_meta.languages { - let macro_ident = format_ident!("impl_{}_proxy", lang.name); - let feature_gate = lang - .on_feature - .map(|feature| quote!(#[cfg(feature=#feature)])) - .unwrap_or_default(); - - tokens.push(TokenStream::from(quote::quote! { - #feature_gate - bevy_mod_scripting::api::#macro_ident!{ - #original_tokens - }; - })); - } - tokens.into_iter().collect() - } - Err(err) => err.to_compile_error().into(), - } -} - /// A convenience macro which derives a lotta things to make your type work in all supported/enabled scripting languages, and provide static typing where possible. /// /// This macro is used extensively in `bevy_mod_scripting/src/generated.rs`, for extensive usage examples see those macro invocations. @@ -94,72 +63,74 @@ pub fn make_script_proxy(input: TokenStream) -> TokenStream { since = "0.3.0" )] pub fn impl_script_newtype(input: TokenStream) -> TokenStream { - let invocation = parse_macro_input!(input as MacroInvocation); - let mut output: proc_macro2::TokenStream = Default::default(); - // find the language implementor macro id's - match invocation.languages.parse_meta() { - Ok(syn::Meta::List(list)) => { - if !list.path.is_ident("languages") { - return syn::Error::new_spanned(list, "Expected `langauges(..)` meta list") - .to_compile_error() - .into(); - } + // let invocation = parse_macro_input!(input as MacroInvocation); + // let inner = invocation.inner; + return input.into(); + // let mut output: proc_macro2::TokenStream = Default::default(); + // // find the language implementor macro id's + // match invocation.languages.parse_meta() { + // Ok(syn::Meta::List(list)) => { + // if !list.path.is_ident("languages") { + // return syn::Error::new_spanned(list, "Expected `langauges(..)` meta list") + // .to_compile_error() + // .into(); + // } - // now create an invocation per language specified - for language in &list.nested { - let mut feature_gate = false; - let mut inner_language = None; - if let syn::NestedMeta::Meta(syn::Meta::List(sub_list)) = language { - if sub_list.path.is_ident("on_feature") { - if let Some(syn::NestedMeta::Meta(syn::Meta::Path(path))) = - sub_list.nested.first() - { - if let Some(ident) = path.get_ident() { - inner_language = Some(ident); - feature_gate = true; - } - } - } - } else if let syn::NestedMeta::Meta(syn::Meta::Path(path)) = language { - if let Some(ident) = path.get_ident() { - inner_language = Some(ident) - } - } + // // now create an invocation per language specified + // for language in &list.nested { + // let mut feature_gate = false; + // let mut inner_language = None; + // if let syn::NestedMeta::Meta(syn::Meta::List(sub_list)) = language { + // if sub_list.path.is_ident("on_feature") { + // if let Some(syn::NestedMeta::Meta(syn::Meta::Path(path))) = + // sub_list.nested.first() + // { + // if let Some(ident) = path.get_ident() { + // inner_language = Some(ident); + // feature_gate = true; + // } + // } + // } + // } else if let syn::NestedMeta::Meta(syn::Meta::Path(path)) = language { + // if let Some(ident) = path.get_ident() { + // inner_language = Some(ident) + // } + // } - let inner_language = - match inner_language { - Some(v) => v, - None => return syn::Error::new_spanned( - language, - "Expected `on_feature(x)` or `x` attribute where x is a valid language", - ) - .to_compile_error() - .into(), - }; + // let inner_language = + // match inner_language { + // Some(v) => v, + // None => return syn::Error::new_spanned( + // language, + // "Expected `on_feature(x)` or `x` attribute where x is a valid language", + // ) + // .to_compile_error() + // .into(), + // }; - let lang_str = inner_language.to_string(); - let macro_ident = format_ident!("impl_{}_newtype", inner_language); - let inner = invocation.inner.clone(); - let feature_gate = feature_gate.then_some(quote::quote!(#[cfg(feature=#lang_str)])); - output.extend(quote_spanned! {language.span()=> - #feature_gate - #macro_ident!{ - #inner - } - }); - } - } - _ => { - return syn::Error::new( - invocation.span(), - "Expected attribute of the form #[languages(..)]", - ) - .to_compile_error() - .into() - } - }; + // let lang_str = inner_language.to_string(); + // let macro_ident = format_ident!("impl_{}_newtype", inner_language); + // let inner = invocation.inner.clone(); + // let feature_gate = feature_gate.then_some(quote::quote!(#[cfg(feature=#lang_str)])); + // output.extend(quote_spanned! {language.span()=> + // #feature_gate + // #macro_ident!{ + // #inner + // } + // }); + // } + // } + // _ => { + // return syn::Error::new( + // invocation.span(), + // "Expected attribute of the form #[languages(..)]", + // ) + // .to_compile_error() + // .into() + // } + // }; - output.into() + // output.into() } pub(crate) struct MacroInvocation { diff --git a/bevy_script_api/src/generated.rs b/bevy_script_api/src/generated.rs index 91ce1a567b..6c1d14fd57 100644 --- a/bevy_script_api/src/generated.rs +++ b/bevy_script_api/src/generated.rs @@ -1,125 +1,12 @@ #![allow(clippy::all, unused_imports, deprecated)] -// This file is generated by `bevy_mod_scripting_derive/main.rs` change the template not this file extern crate self as bevy_script_api; use crate::{ error::ReflectionError, script_ref::{ReflectedValue, ValueIndex}, sub_reflect::ReflectPathElem, }; -use bevy::animation::AnimationPlayer; -use bevy::asset::AssetPathId; -use bevy::asset::HandleId; -use bevy::asset::LabelId; -use bevy::asset::SourcePathId; -use bevy::core::Name; -use bevy::core_pipeline::clear_color::ClearColor; -use bevy::core_pipeline::clear_color::ClearColorConfig; -use bevy::core_pipeline::core_2d::Camera2d; -use bevy::core_pipeline::core_3d::Camera3d; -use bevy::core_pipeline::core_3d::Camera3dDepthLoadOp; -use bevy::ecs::entity::Entity; -use bevy::gltf::GltfExtras; -use bevy::hierarchy::Children; -use bevy::hierarchy::Parent; -use bevy::math::bool::BVec2; -use bevy::math::bool::BVec3; -use bevy::math::bool::BVec3A; -use bevy::math::bool::BVec4; -use bevy::math::bool::BVec4A; -use bevy::math::f32::Affine2; -use bevy::math::f32::Affine3A; -use bevy::math::f32::Mat2; -use bevy::math::f32::Mat3; -use bevy::math::f32::Mat3A; -use bevy::math::f32::Mat4; -use bevy::math::f32::Quat; -use bevy::math::f32::Vec2; -use bevy::math::f32::Vec3; -use bevy::math::f32::Vec3A; -use bevy::math::f32::Vec4; -use bevy::math::f64::DAffine2; -use bevy::math::f64::DAffine3; -use bevy::math::f64::DMat2; -use bevy::math::f64::DMat3; -use bevy::math::f64::DMat4; -use bevy::math::f64::DQuat; -use bevy::math::f64::DVec2; -use bevy::math::f64::DVec3; -use bevy::math::f64::DVec4; -use bevy::math::i32::IVec2; -use bevy::math::i32::IVec3; -use bevy::math::i32::IVec4; -use bevy::math::u32::UVec2; -use bevy::math::u32::UVec3; -use bevy::math::u32::UVec4; -use bevy::math::EulerRot; -use bevy::math::Rect; -use bevy::pbr::wireframe::Wireframe; -use bevy::pbr::wireframe::WireframeConfig; -use bevy::pbr::AlphaMode; -use bevy::pbr::AmbientLight; -use bevy::pbr::CubemapVisibleEntities; -use bevy::pbr::DirectionalLight; -use bevy::pbr::DirectionalLightShadowMap; -use bevy::pbr::NotShadowCaster; -use bevy::pbr::NotShadowReceiver; -use bevy::pbr::PointLight; -use bevy::pbr::PointLightShadowMap; use bevy::prelude::App; -use bevy::reflect::Enum; -use bevy::render::camera::Camera; -use bevy::render::camera::CameraProjection; -use bevy::render::camera::CameraRenderGraph; -use bevy::render::camera::OrthographicProjection; -use bevy::render::camera::PerspectiveProjection; -use bevy::render::camera::Projection; -use bevy::render::camera::RenderTarget; -use bevy::render::camera::ScalingMode; -use bevy::render::camera::Viewport; -use bevy::render::color::Color; -use bevy::render::mesh::skinning::SkinnedMesh; -use bevy::render::primitives::Aabb; -use bevy::render::primitives::CubemapFrusta; -use bevy::render::primitives::Frustum; -use bevy::render::view::visibility::ComputedVisibility; -use bevy::render::view::visibility::RenderLayers; -use bevy::render::view::visibility::Visibility; -use bevy::render::view::visibility::VisibleEntities; -use bevy::render::view::Msaa; -use bevy::sprite::Anchor; -use bevy::sprite::Mesh2dHandle; -use bevy::sprite::Sprite; -use bevy::sprite::TextureAtlasSprite; -use bevy::text::Text; -use bevy::text::Text2dBounds; -use bevy::text::TextAlignment; -use bevy::text::TextSection; -use bevy::text::TextStyle; -use bevy::time::Stopwatch; -use bevy::time::Timer; -use bevy::transform::components::GlobalTransform; -use bevy::transform::components::Transform; -use bevy::ui::widget::Button; -use bevy::ui::AlignContent; -use bevy::ui::AlignItems; -use bevy::ui::AlignSelf; -use bevy::ui::CalculatedClip; -use bevy::ui::Direction; -use bevy::ui::Display; -use bevy::ui::FlexDirection; -use bevy::ui::FlexWrap; -use bevy::ui::FocusPolicy; -use bevy::ui::Interaction; -use bevy::ui::JustifyContent; -use bevy::ui::Node; -use bevy::ui::Overflow; -use bevy::ui::PositionType; -use bevy::ui::Style; -use bevy::ui::UiImage; -use bevy::ui::Val; use bevy_mod_scripting_core::prelude::*; -use bevy_mod_scripting_derive::impl_script_newtype; -use std::ops::*; use std::sync::Mutex; #[cfg(feature = "lua")] use { @@ -128,10073 +15,87731 @@ use { lua::{util::LuaIndex, RegisterForeignLuaType}, }, bevy_mod_scripting_lua::{docs::LuaDocFragment, tealr::mlu::mlua::MetaMethod}, - bevy_mod_scripting_lua_derive::impl_lua_newtype, + bevy_mod_scripting_lua_derive::LuaProxy, }; -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Defines how each line is aligned within the flexbox. - /// - ///It only applies if [`FlexWrap::Wrap`] is present and if there are multiple lines of items. - bevy_ui::AlignContent : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///How items are aligned according to the cross axis - bevy_ui::AlignItems : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///How this item is aligned according to the cross axis. - ///Overrides [`AlignItems`]. - bevy_ui::AlignSelf : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Defines the text direction - /// - ///For example English is written LTR (left-to-right) while Arabic is written RTL (right-to-left). - bevy_ui::Direction : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Defines how flexbox items are ordered within a flexbox - bevy_ui::FlexDirection : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Defines if flexbox items appear on a single line or on multiple lines - bevy_ui::FlexWrap : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Describes whether the node should block interactions with lower nodes - bevy_ui::FocusPolicy : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Describes what type of input interaction has occurred for a UI node. - /// - ///This is commonly queried with a `Changed` filter. - /// - ///Updated in [`ui_focus_system`]. - /// - ///If a UI node has both [`Interaction`] and [`ComputedVisibility`] components, - ///[`Interaction`] will always be [`Interaction::None`] - ///when [`ComputedVisibility::is_visible()`] is false. - ///This ensures that hidden UI nodes are not interactable, - ///and do not end up stuck in an active state if hidden at the wrong time. - /// - ///Note that you can also control the visibility of a node using the [`Display`](crate::ui_node::Display) property, - ///which fully collapses it during layout calculations. - bevy_ui::Interaction : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Defines how items are aligned according to the main axis - bevy_ui::JustifyContent : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Whether to show or hide overflowing items - bevy_ui::Overflow : - Clone + - Debug + - Methods - ( - ///Show overflowing items on both axes - visible() -> self, - - ///Clip overflowing items on both axes - clip() -> self, - - ///Clip overflowing items on the x axis - clip_x() -> self, - - ///Clip overflowing items on the y axis - clip_y() -> self, - - ///Overflow is visible on both axes - is_visible(&self:) -> Raw(bool), - - ) - + Fields - ( - /// Whether to show or clip overflowing items on the x axis - x: Raw(ReflectedValue), - /// Whether to show or clip overflowing items on the y axis - y: Raw(ReflectedValue), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///The strategy used to position this node - bevy_ui::PositionType : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Represents the possible value types for layout properties. - /// - ///This enum allows specifying values for various [`Style`] properties in different units, - ///such as logical pixels, percentages, or automatically determined values. - bevy_ui::Val : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - self Div Raw(f32) -> Wrapped(Val), - self Mul Raw(f32) -> Wrapped(Val), - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///The calculated clip of the node - bevy_ui::CalculatedClip : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - /// The rect of the clip - clip: Wrapped(Rect), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Describes the size of a UI node - bevy_ui::Node : - Clone + - Debug + - Methods - ( - ///The calculated node size as width and height in logical pixels - ///automatically calculated by [`super::layout::ui_layout_system`] - size(&self:) -> Wrapped(Vec2), - - ///Returns the size of the node in physical pixels based on the given scale factor and `UiScale`. - physical_size(&self:Raw(f64),Raw(f64)) -> Wrapped(Vec2), - - ///Returns the logical pixel coordinates of the UI node, based on its [`GlobalTransform`]. - logical_rect(&self:Wrapped(&GlobalTransform)) -> Wrapped(Rect), - - ///Returns the physical pixel coordinates of the UI node, based on its [`GlobalTransform`] and the scale factor. - physical_rect(&self:Wrapped(&GlobalTransform),Raw(f64),Raw(f64)) -> Wrapped(Rect), - - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Describes the style of a UI container node - /// - ///Node's can be laid out using either Flexbox or CSS Grid Layout.
- ///See below for general learning resources and for documentation on the individual style properties. - /// - ///### Flexbox - /// - ///- [MDN: Basic Concepts of Grid Layout](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Basic_Concepts_of_Grid_Layout) - ///- [A Complete Guide To Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) by CSS Tricks. This is detailed guide with illustrations and comphrehensive written explanation of the different Flexbox properties and how they work. - ///- [Flexbox Froggy](https://flexboxfroggy.com/). An interactive tutorial/game that teaches the essential parts of Flebox in a fun engaging way. - /// - ///### CSS Grid - /// - ///- [MDN: Basic Concepts of Flexbox](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox) - ///- [A Complete Guide To CSS Grid](https://css-tricks.com/snippets/css/complete-guide-grid/) by CSS Tricks. This is detailed guide with illustrations and comphrehensive written explanation of the different CSS Grid properties and how they work. - ///- [CSS Grid Garden](https://cssgridgarden.com/). An interactive tutorial/game that teaches the essential parts of CSS Grid in a fun engaging way. - bevy_ui::Style : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - /// Which layout algorithm to use when laying out this node's contents: - /// - [`Display::Flex`]: Use the Flexbox layout algorithm - /// - [`Display::Grid`]: Use the CSS Grid layout algorithm - /// - [`Display::None`]: Hide this node and perform layout as if it does not exist. - /// - /// - display: Wrapped(Display), - /// Whether a node should be laid out in-flow with, or independently of it's siblings: - /// - [`PositionType::Relative`]: Layout this node in-flow with other nodes using the usual (flexbox/grid) layout algorithm. - /// - [`PositionType::Absolute`]: Layout this node on top and independently of other nodes. - /// - /// - position_type: Wrapped(PositionType), - /// Whether overflowing content should be displayed or clipped. - /// - /// - overflow: Wrapped(Overflow), - /// Defines the text direction. For example English is written LTR (left-to-right) while Arabic is written RTL (right-to-left). - /// - /// Note: the corresponding CSS property also affects box layout order, but this isn't yet implemented in bevy. - /// - direction: Wrapped(Direction), - /// The horizontal position of the left edge of the node. - /// - For relatively positioned nodes, this is relative to the node's position as computed during regular layout. - /// - For absolutely positioned nodes, this is relative to the *parent* node's bounding box. - /// - /// - left: Wrapped(Val), - /// The horizontal position of the right edge of the node. - /// - For relatively positioned nodes, this is relative to the node's position as computed during regular layout. - /// - For absolutely positioned nodes, this is relative to the *parent* node's bounding box. - /// - /// - right: Wrapped(Val), - /// The vertical position of the top edge of the node. - /// - For relatively positioned nodes, this is relative to the node's position as computed during regular layout. - /// - For absolutely positioned nodes, this is relative to the *parent* node's bounding box. - /// - /// - top: Wrapped(Val), - /// The vertical position of the bottom edge of the node. - /// - For relatively positioned nodes, this is relative to the node's position as computed during regular layout. - /// - For absolutely positioned nodes, this is relative to the *parent* node's bounding box. - /// - /// - bottom: Wrapped(Val), - /// The ideal width of the node. `width` is used when it is within the bounds defined by `min_width` and `max_width`. - /// - /// - width: Wrapped(Val), - /// The ideal height of the node. `height` is used when it is within the bounds defined by `min_height` and `max_height`. - /// - /// - height: Wrapped(Val), - /// The minimum width of the node. `min_width` is used if it is greater than either `width` and/or `max_width`. - /// - /// - min_width: Wrapped(Val), - /// The minimum height of the node. `min_height` is used if it is greater than either `height` and/or `max_height`. - /// - /// - min_height: Wrapped(Val), - /// The maximum width of the node. `max_width` is used if it is within the bounds defined by `min_width` and `width`. - /// - /// - max_width: Wrapped(Val), - /// The maximum height of the node. `max_height` is used if it is within the bounds defined by `min_height` and `height`. - /// - /// - max_height: Wrapped(Val), - /// The aspect ratio of the node (defined as `width / height`) - /// - /// - aspect_ratio: Raw(ReflectedValue), - /// For Flexbox containers: - /// - Sets default cross-axis alignment of the child items. - /// For CSS Grid containers: - /// - Controls block (vertical) axis alignment of children of this grid container within their grid areas - /// - /// This value is overriden [`JustifySelf`] on the child node is set. - /// - /// - align_items: Wrapped(AlignItems), - /// For Flexbox containers: - /// - This property has no effect. See `justify_content` for main-axis alignment of flex items. - /// For CSS Grid containers: - /// - Sets default inline (horizontal) axis alignment of child items within their grid areas - /// - /// This value is overriden [`JustifySelf`] on the child node is set. - /// - /// - justify_items: Raw(ReflectedValue), - /// For Flexbox items: - /// - Controls cross-axis alignment of the item. - /// For CSS Grid items: - /// - Controls block (vertical) axis alignment of a grid item within it's grid area - /// - /// If set to `Auto`, alignment is inherited from the value of [`AlignItems`] set on the parent node. - /// - /// - align_self: Wrapped(AlignSelf), - /// For Flexbox items: - /// - This property has no effect. See `justify_content` for main-axis alignment of flex items. - /// For CSS Grid items: - /// - Controls inline (horizontal) axis alignment of a grid item within it's grid area. - /// - /// If set to `Auto`, alignment is inherited from the value of [`JustifyItems`] set on the parent node. - /// - /// - justify_self: Raw(ReflectedValue), - /// For Flexbox containers: - /// - Controls alignment of lines if flex_wrap is set to [`FlexWrap::Wrap`] and there are multiple lines of items - /// For CSS Grid container: - /// - Controls alignment of grid rows - /// - /// - align_content: Wrapped(AlignContent), - /// For Flexbox containers: - /// - Controls alignment of items in the main axis - /// For CSS Grid containers: - /// - Controls alignment of grid columns - /// - /// - justify_content: Wrapped(JustifyContent), - /// The amount of space around a node outside its border. - /// - /// If a percentage value is used, the percentage is calculated based on the width of the parent node. - /// - /// # Example - /// ``` - /// # use bevy_ui::{Style, UiRect, Val}; - /// let style = Style { - /// margin: UiRect { - /// left: Val::Percent(10.), - /// right: Val::Percent(10.), - /// top: Val::Percent(15.), - /// bottom: Val::Percent(15.) - /// }, - /// ..Default::default() - /// }; - /// ``` - /// A node with this style and a parent with dimensions of 100px by 300px, will have calculated margins of 10px on both left and right edges, and 15px on both top and bottom edges. - /// - /// - margin: Raw(ReflectedValue), - /// The amount of space between the edges of a node and its contents. - /// - /// If a percentage value is used, the percentage is calculated based on the width of the parent node. - /// - /// # Example - /// ``` - /// # use bevy_ui::{Style, UiRect, Val}; - /// let style = Style { - /// padding: UiRect { - /// left: Val::Percent(1.), - /// right: Val::Percent(2.), - /// top: Val::Percent(3.), - /// bottom: Val::Percent(4.) - /// }, - /// ..Default::default() - /// }; - /// ``` - /// A node with this style and a parent with dimensions of 300px by 100px, will have calculated padding of 3px on the left, 6px on the right, 9px on the top and 12px on the bottom. - /// - /// - padding: Raw(ReflectedValue), - /// The amount of space between the margins of a node and its padding. - /// - /// If a percentage value is used, the percentage is calculated based on the width of the parent node. - /// - /// The size of the node will be expanded if there are constraints that prevent the layout algorithm from placing the border within the existing node boundary. - /// - /// Rendering for borders is not yet implemented. - /// - /// - border: Raw(ReflectedValue), - /// Whether a Flexbox container should be a row or a column. This property has no effect of Grid nodes. - /// - /// - flex_direction: Wrapped(FlexDirection), - /// Whether a Flexbox container should wrap it's contents onto multiple line wrap if they overflow. This property has no effect of Grid nodes. - /// - /// - flex_wrap: Wrapped(FlexWrap), - /// Defines how much a flexbox item should grow if there's space available. Defaults to 0 (don't grow at all). - /// - /// - flex_grow: Raw(f32), - /// Defines how much a flexbox item should shrink if there's not enough space available. Defaults to 1. - /// - /// - flex_shrink: Raw(f32), - /// The initial length of a flexbox in the main axis, before flex growing/shrinking properties are applied. - /// - /// `flex_basis` overrides `size` on the main axis if both are set, but it obeys the bounds defined by `min_size` and `max_size`. - /// - /// - flex_basis: Wrapped(Val), - /// The size of the gutters between items in a vertical flexbox layout or between rows in a grid layout - /// - /// Note: Values of `Val::Auto` are not valid and are treated as zero. - /// - /// - row_gap: Wrapped(Val), - /// The size of the gutters between items in a horizontal flexbox layout or between column in a grid layout - /// - /// Note: Values of `Val::Auto` are not valid and are treated as zero. - /// - /// - column_gap: Wrapped(Val), - /// Controls whether automatically placed grid items are placed row-wise or column-wise. And whether the sparse or dense packing algorithm is used. - /// Only affect Grid layouts - /// - /// - grid_auto_flow: Raw(ReflectedValue), - /// Defines the number of rows a grid has and the sizes of those rows. If grid items are given explicit placements then more rows may - /// be implicitly generated by items that are placed out of bounds. The sizes of those rows are controlled by `grid_auto_rows` property. - /// - /// - grid_template_rows: Raw(ReflectedValue), - /// Defines the number of columns a grid has and the sizes of those columns. If grid items are given explicit placements then more columns may - /// be implicitly generated by items that are placed out of bounds. The sizes of those columns are controlled by `grid_auto_columns` property. - /// - /// - grid_template_columns: Raw(ReflectedValue), - /// Defines the size of implicitly created rows. Rows are created implicitly when grid items are given explicit placements that are out of bounds - /// of the rows explicitly created using `grid_template_rows`. - /// - /// - grid_auto_rows: Raw(ReflectedValue), - /// Defines the size of implicitly created columns. Columns are created implicitly when grid items are given explicit placements that are out of bounds - /// of the columns explicitly created using `grid_template_columms`. - /// - /// - grid_auto_columns: Raw(ReflectedValue), - /// The row in which a grid item starts and how many rows it spans. - /// - /// - grid_row: Raw(ReflectedValue), - /// The column in which a grid item starts and how many columns it spans. - /// - /// - grid_column: Raw(ReflectedValue), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///The 2D texture displayed for this UI node - bevy_ui::UiImage : - Clone + - Debug + - Methods - ( - ///flip the image along its x-axis - with_flip_x(self:) -> self, - - ///flip the image along its y-axis - with_flip_y(self:) -> self, - - ) - + Fields - ( - /// Handle to the texture - texture: Raw(ReflectedValue), - /// Whether the image should be flipped along its x-axis - flip_x: Raw(bool), - /// Whether the image should be flipped along its y-axis - flip_y: Raw(bool), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Marker struct for buttons - bevy_ui::widget::Button : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Whether to use a Flexbox layout model. - /// - ///Part of the [`Style`] component. - bevy_ui::Display : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Animation controls - bevy_animation::AnimationPlayer : - Methods - ( - ///Pause the animation - pause(&mut self:), - - ///Unpause the animation - resume(&mut self:), - - ///Is the animation paused - is_paused(&self:) -> Raw(bool), - - ///Speed of the animation playback - speed(&self:) -> Raw(f32), - - ///Time elapsed playing the animation - elapsed(&self:) -> Raw(f32), - - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Component used to identify an entity. Stores a hash for faster comparisons. - /// - ///The hash is eagerly re-computed upon each update to the name. - /// - ///[`Name`] should not be treated as a globally unique identifier for entities, - ///as multiple entities can have the same name. [`bevy_ecs::entity::Entity`] should be - ///used instead as the default unique identifier. - bevy_core::Name : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - bevy_gltf::GltfExtras : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - value: Raw(String), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Contains references to the child entities of this entity. - /// - ///See [`HierarchyQueryExt`] for hierarchy related methods on [`Query`]. - /// - ///[`HierarchyQueryExt`]: crate::query_extension::HierarchyQueryExt - ///[`Query`]: bevy_ecs::system::Query - bevy_hierarchy::Children : - Debug + - Methods - ( - ///Swaps the child at `a_index` with the child at `b_index`. - swap(&mut self:Raw(usize),Raw(usize)), - - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Holds a reference to the parent entity of this entity. - ///This component should only be present on entities that actually have a parent entity. - /// - ///See [`HierarchyQueryExt`] for hierarchy related methods on [`Query`]. - /// - ///[`HierarchyQueryExt`]: crate::query_extension::HierarchyQueryExt - ///[`Query`]: bevy_ecs::system::Query - bevy_hierarchy::Parent : - Debug + - Methods - ( - ///Gets the [`Entity`] ID of the parent. - get(&self:) -> Wrapped(Entity), - - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///The maximum width and height of text. The text will wrap according to the specified size. - ///Characters out of the bounds after wrapping will be truncated. Text is aligned according to the - ///specified [`TextAlignment`](crate::text::TextAlignment). - /// - ///Note: only characters that are completely out of the bounds will be truncated, so this is not a - ///reliable limit if it is necessary to contain the text strictly in the bounds. Currently this - ///component is mainly useful for text wrapping only. - bevy_text::Text2dBounds : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - size: Wrapped(Vec2), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - bevy_text::Text : - Clone + - Debug + - Methods - ( - ///Returns this [`Text`] with a new [`TextAlignment`]. - with_alignment(self:Wrapped(TextAlignment)) -> self, - - ///Returns this [`Text`] with soft wrapping disabled. - ///Hard wrapping, where text contains an explicit linebreak such as the escape sequence `\n`, will still occur. - with_no_wrap(self:) -> self, - - ) - + Fields - ( - sections: Raw(ReflectedValue), - /// The text's internal alignment. - /// Should not affect its position within a container. - alignment: Wrapped(TextAlignment), - /// How the text should linebreak when running out of the bounds determined by max_size - linebreak_behavior: Raw(ReflectedValue), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Describes horizontal alignment preference for positioning & bounds. - bevy_text::TextAlignment : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - bevy_text::TextSection : - Clone + - Debug + - Methods - ( - ///Create an empty [`TextSection`] from a style. Useful when the value will be set dynamically. - from_style(Wrapped(TextStyle)) -> self, - - ) - + Fields - ( - value: Raw(String), - style: Wrapped(TextStyle), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - bevy_text::TextStyle : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - font: Raw(ReflectedValue), - font_size: Raw(f32), - color: Wrapped(Color), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A Stopwatch is a struct that track elapsed time when started. +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::ui::AlignContent", functions[])] +pub struct AlignContent; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::ui::AlignItems", functions[])] +pub struct AlignItems; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::ui::AlignSelf", functions[])] +pub struct AlignSelf; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::ui::Direction", functions[])] +pub struct Direction; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::ui::FlexDirection", functions[])] +pub struct FlexDirection; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::ui::FlexWrap", functions[])] +pub struct FlexWrap; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::ui::FocusPolicy", functions[])] +pub struct FocusPolicy; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::ui::Interaction", functions[])] +pub struct Interaction; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::ui::JustifyContent", functions[])] +pub struct JustifyContent; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::ui::Overflow", + functions[r#" + + ///Show overflowing items on both axes + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn visible ( + + ) + + + -> Self + + ; +"#, + r#" + + ///Clip overflowing items on both axes + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn clip ( + + ) + + + -> Self + + ; +"#, + r#" + + ///Clip overflowing items on the x axis + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn clip_x ( + + ) + + + -> Self + + ; +"#, + r#" + + ///Clip overflowing items on the y axis + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn clip_y ( + + ) + + + -> Self + + ; +"#, + r#" + + ///Overflow is visible on both axes + + #[lua( + + + + )] + fn is_visible ( + + + &self, + + + ) + + + -> bool + + ; +"#, + ] +)] +pub struct Overflow; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::ui::PositionType", functions[])] +pub struct PositionType; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::ui::Val", functions[])] +pub struct Val; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::ui::CalculatedClip", functions[])] +pub struct CalculatedClip; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::ui::Node", + functions[r#" + + ///The calculated node size as width and height in logical pixels + + ///automatically calculated by [`super::layout::ui_layout_system`] + + #[lua( + + + + output(proxy), + + )] + fn size ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + ///Returns the size of the node in physical pixels based on the given scale factor and `UiScale`. + + #[lua( + + + + output(proxy), + + )] + fn physical_size ( + + + &self, + + + + + scale_factor : f64, + + + + + + ui_scale : f64, + + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + ///Returns the logical pixel coordinates of the UI node, based on its [`GlobalTransform`]. + + #[lua( + + + + output(proxy), + + )] + fn logical_rect ( + + + &self, + + + + + #[proxy] + + transform : &bevy::transform::components::GlobalTransform, + + + + ) + + + -> bevy::math::Rect + + ; +"#, + r#" + + ///Returns the physical pixel coordinates of the UI node, based on its [`GlobalTransform`] and the scale factor. + + #[lua( + + + + output(proxy), + + )] + fn physical_rect ( + + + &self, + + + + + #[proxy] + + transform : &bevy::transform::components::GlobalTransform, + + + + + + scale_factor : f64, + + + + + + ui_scale : f64, + + + + ) + + + -> bevy::math::Rect + + ; +"#, + ] +)] +pub struct Node; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::ui::Style", functions[])] +pub struct Style; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::ui::UiImage", + functions[r#" + + ///flip the image along its x-axis + + #[lua( + + + + output(proxy), + + )] + fn with_flip_x ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///flip the image along its y-axis + + #[lua( + + + + output(proxy), + + )] + fn with_flip_y ( + + + self, + + + ) + + + -> Self + + ; +"#, + ] +)] +pub struct UiImage; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::ui::widget::Button", functions[])] +pub struct Button; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::ui::Display", functions[])] +pub struct Display; +#[derive(LuaProxy)] +#[proxy( + derive(), + remote = "bevy::animation::AnimationPlayer", + functions[r#" + + ///Pause the animation + + #[lua( + + + + )] + fn pause ( + + + &mut self, + + + ) + ; +"#, + r#" + + ///Unpause the animation + + #[lua( + + + + )] + fn resume ( + + + &mut self, + + + ) + ; +"#, + r#" + + ///Is the animation paused + + #[lua( + + + + )] + fn is_paused ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Speed of the animation playback + + #[lua( + + + + )] + fn speed ( + + + &self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Time elapsed playing the animation + + #[lua( + + + + )] + fn elapsed ( + + + &self, + + + ) + + + -> f32 + + ; +"#, + ] +)] +pub struct AnimationPlayer; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::core::Name", functions[])] +pub struct Name; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::gltf::GltfExtras", functions[])] +pub struct GltfExtras; +#[derive(LuaProxy)] +#[proxy( + derive(debug), + remote = "bevy::hierarchy::Children", + functions[r#" + + ///Swaps the child at `a_index` with the child at `b_index`. + + #[lua( + + + + )] + fn swap ( + + + &mut self, + + + + + a_index : usize, + + + + + + b_index : usize, + + + + ) + ; +"#, + ] +)] +pub struct Children; +#[derive(LuaProxy)] +#[proxy( + derive(debug), + remote = "bevy::hierarchy::Parent", + functions[r#" + + ///Gets the [`Entity`] ID of the parent. + + #[lua( + + + + output(proxy), + + )] + fn get ( + + + &self, + + + ) + + + -> bevy::ecs::entity::Entity + + ; +"#, + ] +)] +pub struct Parent; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::text::Text2dBounds", functions[])] +pub struct Text2dBounds; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::text::Text", + functions[r#" + + ///Returns this [`Text`] with a new [`TextAlignment`]. + + #[lua( + + + + output(proxy), + + )] + fn with_alignment ( + + + self, + + + + + #[proxy] + + alignment : bevy::text::TextAlignment, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns this [`Text`] with soft wrapping disabled. + + ///Hard wrapping, where text contains an explicit linebreak such as the escape sequence `\n`, will still occur. + + #[lua( + + + + output(proxy), + + )] + fn with_no_wrap ( + + + self, + + + ) + + + -> Self + + ; +"#, + ] +)] +pub struct Text; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::text::TextAlignment", functions[])] +pub struct TextAlignment; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::text::TextSection", + functions[r#" + + ///Create an empty [`TextSection`] from a style. Useful when the value will be set dynamically. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_style ( + + + + #[proxy] + + style : bevy::text::TextStyle, + + + + ) + + + -> Self + + ; +"#, + ] +)] +pub struct TextSection; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::text::TextStyle", functions[])] +pub struct TextStyle; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::time::Stopwatch", + functions[r#" + + ///Create a new unpaused `Stopwatch` with no elapsed time. + /// + ///# Examples + + ///``` + + ///# use bevy_time::*; + + ///let stopwatch = Stopwatch::new(); + + ///assert_eq!(stopwatch.elapsed_secs(), 0.0); + + ///assert_eq!(stopwatch.paused(), false); + + ///``` + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn new ( + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the elapsed time since the last [`reset`](Stopwatch::reset) + + ///of the stopwatch, in seconds. + /// + + ///# Examples + ///``` + ///# use bevy_time::*; + ///use std::time::Duration; + ///let mut stopwatch = Stopwatch::new(); - ///assert_eq!(stopwatch.elapsed_secs(), 0.0); - /// - ///stopwatch.tick(Duration::from_secs_f32(1.0)); // tick one second + + ///stopwatch.tick(Duration::from_secs(1)); + ///assert_eq!(stopwatch.elapsed_secs(), 1.0); + + ///``` + + /// + + ///# See Also + + /// + + ///[`elapsed`](Stopwatch::elapsed) - if a `Duration` is desirable instead. + + ///[`elapsed_secs_f64`](Stopwatch::elapsed_secs_f64) - if an `f64` is desirable instead. + + #[lua( + + + + )] + fn elapsed_secs ( + + + &self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns the elapsed time since the last [`reset`](Stopwatch::reset) + + ///of the stopwatch, in seconds, as f64. + + /// + + ///# See Also + + /// + + ///[`elapsed`](Stopwatch::elapsed) - if a `Duration` is desirable instead. + + ///[`elapsed_secs`](Stopwatch::elapsed_secs) - if an `f32` is desirable instead. + + #[lua( + + + + )] + fn elapsed_secs_f64 ( + + + &self, + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Pauses the stopwatch. Any call to [`tick`](Stopwatch::tick) while + + ///paused will not have any effect on the elapsed time. + + /// + + ///# Examples + + ///``` + + ///# use bevy_time::*; + + ///use std::time::Duration; + + ///let mut stopwatch = Stopwatch::new(); + + ///stopwatch.pause(); + + ///stopwatch.tick(Duration::from_secs_f32(1.5)); + + ///assert!(stopwatch.paused()); + + ///assert_eq!(stopwatch.elapsed_secs(), 0.0); + + ///``` + + #[lua( + + + + )] + fn pause ( + + + &mut self, + + + ) + ; +"#, + r#" + + ///Unpauses the stopwatch. Resume the effect of ticking on elapsed time. + /// + + ///# Examples + + ///``` + + ///# use bevy_time::*; + + ///use std::time::Duration; + + ///let mut stopwatch = Stopwatch::new(); + ///stopwatch.pause(); - ///stopwatch.tick(Duration::from_secs_f32(1.0)); // paused stopwatches don't tick + + ///stopwatch.tick(Duration::from_secs_f32(1.0)); + + ///stopwatch.unpause(); + + ///stopwatch.tick(Duration::from_secs_f32(1.0)); + + ///assert!(!stopwatch.paused()); + ///assert_eq!(stopwatch.elapsed_secs(), 1.0); + + ///``` + + #[lua( + + + + )] + fn unpause ( + + + &mut self, + + + ) + ; +"#, + r#" + + ///Returns `true` if the stopwatch is paused. + /// - ///stopwatch.reset(); // reset the stopwatch + + ///# Examples + + ///``` + + ///# use bevy_time::*; + + ///let mut stopwatch = Stopwatch::new(); + + ///assert!(!stopwatch.paused()); + + ///stopwatch.pause(); + ///assert!(stopwatch.paused()); + + ///stopwatch.unpause(); + + ///assert!(!stopwatch.paused()); + + ///``` + + #[lua( + + + + )] + fn paused ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Resets the stopwatch. The reset doesn't affect the paused state of the stopwatch. + + /// + + ///# Examples + + ///``` + + ///# use bevy_time::*; + + ///use std::time::Duration; + + ///let mut stopwatch = Stopwatch::new(); + + ///stopwatch.tick(Duration::from_secs_f32(1.5)); + + ///stopwatch.reset(); + ///assert_eq!(stopwatch.elapsed_secs(), 0.0); + ///``` - bevy_time::Stopwatch : - Clone + - Debug + - Methods - ( - ///Create a new unpaused `Stopwatch` with no elapsed time. - /// - ///# Examples - ///``` - ///# use bevy_time::*; - ///let stopwatch = Stopwatch::new(); - ///assert_eq!(stopwatch.elapsed_secs(), 0.0); - ///assert_eq!(stopwatch.paused(), false); - ///``` - new() -> self, - - ///Returns the elapsed time since the last [`reset`](Stopwatch::reset) - ///of the stopwatch, in seconds. - /// - ///# Examples - ///``` - ///# use bevy_time::*; - ///use std::time::Duration; - ///let mut stopwatch = Stopwatch::new(); - ///stopwatch.tick(Duration::from_secs(1)); - ///assert_eq!(stopwatch.elapsed_secs(), 1.0); - ///``` - /// - ///# See Also - /// - ///[`elapsed`](Stopwatch::elapsed) - if a `Duration` is desirable instead. - ///[`elapsed_secs_f64`](Stopwatch::elapsed_secs_f64) - if an `f64` is desirable instead. - elapsed_secs(&self:) -> Raw(f32), - - ///Returns the elapsed time since the last [`reset`](Stopwatch::reset) - ///of the stopwatch, in seconds, as f64. - /// - ///# See Also - /// - ///[`elapsed`](Stopwatch::elapsed) - if a `Duration` is desirable instead. - ///[`elapsed_secs`](Stopwatch::elapsed_secs) - if an `f32` is desirable instead. - elapsed_secs_f64(&self:) -> Raw(f64), - - ///Pauses the stopwatch. Any call to [`tick`](Stopwatch::tick) while - ///paused will not have any effect on the elapsed time. - /// - ///# Examples - ///``` - ///# use bevy_time::*; - ///use std::time::Duration; - ///let mut stopwatch = Stopwatch::new(); - ///stopwatch.pause(); - ///stopwatch.tick(Duration::from_secs_f32(1.5)); - ///assert!(stopwatch.paused()); - ///assert_eq!(stopwatch.elapsed_secs(), 0.0); - ///``` - pause(&mut self:), - - ///Unpauses the stopwatch. Resume the effect of ticking on elapsed time. - /// - ///# Examples - ///``` - ///# use bevy_time::*; - ///use std::time::Duration; - ///let mut stopwatch = Stopwatch::new(); - ///stopwatch.pause(); - ///stopwatch.tick(Duration::from_secs_f32(1.0)); - ///stopwatch.unpause(); - ///stopwatch.tick(Duration::from_secs_f32(1.0)); - ///assert!(!stopwatch.paused()); - ///assert_eq!(stopwatch.elapsed_secs(), 1.0); - ///``` - unpause(&mut self:), - - ///Returns `true` if the stopwatch is paused. - /// - ///# Examples - ///``` - ///# use bevy_time::*; - ///let mut stopwatch = Stopwatch::new(); - ///assert!(!stopwatch.paused()); - ///stopwatch.pause(); - ///assert!(stopwatch.paused()); - ///stopwatch.unpause(); - ///assert!(!stopwatch.paused()); - ///``` - paused(&self:) -> Raw(bool), - - ///Resets the stopwatch. The reset doesn't affect the paused state of the stopwatch. - /// - ///# Examples - ///``` - ///# use bevy_time::*; - ///use std::time::Duration; - ///let mut stopwatch = Stopwatch::new(); - ///stopwatch.tick(Duration::from_secs_f32(1.5)); - ///stopwatch.reset(); - ///assert_eq!(stopwatch.elapsed_secs(), 0.0); - ///``` - reset(&mut self:), - - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Tracks elapsed time. Enters the finished state once `duration` is reached. - /// - ///Non repeating timers will stop tracking and stay in the finished state until reset. - ///Repeating timers will only be in the finished state on each tick `duration` is reached or - ///exceeded, and can still be reset at any given point. - /// - ///Paused timers will not have elapsed time increased. - bevy_time::Timer : - Clone + - Debug + - Methods - ( - ///Returns `true` if the timer has reached its duration at least once. - ///See also [`Timer::just_finished`](Timer::just_finished). - /// - ///# Examples - ///``` - ///# use bevy_time::*; - ///use std::time::Duration; - ///let mut timer = Timer::from_seconds(1.0, TimerMode::Once); - ///timer.tick(Duration::from_secs_f32(1.5)); - ///assert!(timer.finished()); - ///timer.tick(Duration::from_secs_f32(0.5)); - ///assert!(timer.finished()); - ///``` - finished(&self:) -> Raw(bool), - - ///Returns `true` only on the tick the timer reached its duration. - /// - ///# Examples - ///``` - ///# use bevy_time::*; - ///use std::time::Duration; - ///let mut timer = Timer::from_seconds(1.0, TimerMode::Once); - ///timer.tick(Duration::from_secs_f32(1.5)); - ///assert!(timer.just_finished()); - ///timer.tick(Duration::from_secs_f32(0.5)); - ///assert!(!timer.just_finished()); - ///``` - just_finished(&self:) -> Raw(bool), - - ///Returns the time elapsed on the timer as an `f32`. - ///See also [`Timer::elapsed`](Timer::elapsed). - elapsed_secs(&self:) -> Raw(f32), - - ///Pauses the Timer. Disables the ticking of the timer. - /// - ///See also [`Stopwatch::pause`](Stopwatch::pause). - /// - ///# Examples - ///``` - ///# use bevy_time::*; - ///use std::time::Duration; - ///let mut timer = Timer::from_seconds(1.0, TimerMode::Once); - ///timer.pause(); - ///timer.tick(Duration::from_secs_f32(0.5)); - ///assert_eq!(timer.elapsed_secs(), 0.0); - ///``` - pause(&mut self:), - - ///Unpauses the Timer. Resumes the ticking of the timer. - /// - ///See also [`Stopwatch::unpause()`](Stopwatch::unpause). - /// - ///# Examples - ///``` - ///# use bevy_time::*; - ///use std::time::Duration; - ///let mut timer = Timer::from_seconds(1.0, TimerMode::Once); - ///timer.pause(); - ///timer.tick(Duration::from_secs_f32(0.5)); - ///timer.unpause(); - ///timer.tick(Duration::from_secs_f32(0.5)); - ///assert_eq!(timer.elapsed_secs(), 0.5); - ///``` - unpause(&mut self:), - - ///Returns `true` if the timer is paused. - /// - ///See also [`Stopwatch::paused`](Stopwatch::paused). - /// - ///# Examples - ///``` - ///# use bevy_time::*; - ///let mut timer = Timer::from_seconds(1.0, TimerMode::Once); - ///assert!(!timer.paused()); - ///timer.pause(); - ///assert!(timer.paused()); - ///timer.unpause(); - ///assert!(!timer.paused()); - ///``` - paused(&self:) -> Raw(bool), - - ///Resets the timer. The reset doesn't affect the `paused` state of the timer. - /// - ///See also [`Stopwatch::reset`](Stopwatch::reset). - /// - ///Examples - ///``` - ///# use bevy_time::*; - ///use std::time::Duration; - ///let mut timer = Timer::from_seconds(1.0, TimerMode::Once); - ///timer.tick(Duration::from_secs_f32(1.5)); - ///timer.reset(); - ///assert!(!timer.finished()); - ///assert!(!timer.just_finished()); - ///assert_eq!(timer.elapsed_secs(), 0.0); - ///``` - reset(&mut self:), - - ///Returns the percentage of the timer elapsed time (goes from 0.0 to 1.0). - /// - ///# Examples - ///``` - ///# use bevy_time::*; - ///use std::time::Duration; - ///let mut timer = Timer::from_seconds(2.0, TimerMode::Once); - ///timer.tick(Duration::from_secs_f32(0.5)); - ///assert_eq!(timer.percent(), 0.25); - ///``` - percent(&self:) -> Raw(f32), - - ///Returns the percentage of the timer remaining time (goes from 1.0 to 0.0). - /// - ///# Examples - ///``` - ///# use bevy_time::*; - ///use std::time::Duration; - ///let mut timer = Timer::from_seconds(2.0, TimerMode::Once); - ///timer.tick(Duration::from_secs_f32(0.5)); - ///assert_eq!(timer.percent_left(), 0.75); - ///``` - percent_left(&self:) -> Raw(f32), - - ///Returns the remaining time in seconds - /// - ///# Examples - ///``` - ///# use bevy_time::*; - ///use std::cmp::Ordering; - ///use std::time::Duration; - ///let mut timer = Timer::from_seconds(2.0, TimerMode::Once); - ///timer.tick(Duration::from_secs_f32(0.5)); - ///let result = timer.remaining_secs().total_cmp(&1.5); - ///assert_eq!(Ordering::Equal, result); - ///``` - remaining_secs(&self:) -> Raw(f32), - - ///Returns the number of times a repeating timer - ///finished during the last [`tick`](Timer::tick) call. - /// - ///For non repeating-timers, this method will only ever - ///return 0 or 1. - /// - ///# Examples - ///``` - ///# use bevy_time::*; - ///use std::time::Duration; - ///let mut timer = Timer::from_seconds(1.0, TimerMode::Repeating); - ///timer.tick(Duration::from_secs_f32(6.0)); - ///assert_eq!(timer.times_finished_this_tick(), 6); - ///timer.tick(Duration::from_secs_f32(2.0)); - ///assert_eq!(timer.times_finished_this_tick(), 2); - ///timer.tick(Duration::from_secs_f32(0.5)); - ///assert_eq!(timer.times_finished_this_tick(), 0); - ///``` - times_finished_this_tick(&self:) -> Raw(u32), - - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Lightweight identifier of an [entity](crate::entity). + + #[lua( + + + + )] + fn reset ( + + + &mut self, + + + ) + ; +"#, + ] +)] +pub struct Stopwatch; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::time::Timer", + functions[r#" + + ///Returns `true` if the timer has reached its duration at least once. + + ///See also [`Timer::just_finished`](Timer::just_finished). + /// - ///The identifier is implemented using a [generational index]: a combination of an index and a generation. - ///This allows fast insertion after data removal in an array while minimizing loss of spatial locality. + + ///# Examples + + ///``` + + ///# use bevy_time::*; + + ///use std::time::Duration; + + ///let mut timer = Timer::from_seconds(1.0, TimerMode::Once); + + ///timer.tick(Duration::from_secs_f32(1.5)); + + ///assert!(timer.finished()); + + ///timer.tick(Duration::from_secs_f32(0.5)); + + ///assert!(timer.finished()); + + ///``` + + #[lua( + + + + )] + fn finished ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns `true` only on the tick the timer reached its duration. + /// - ///These identifiers are only valid on the [`World`] it's sourced from. Attempting to use an `Entity` to - ///fetch entity components or metadata from a different world will either fail or return unexpected results. + + ///# Examples + + ///``` + + ///# use bevy_time::*; + + ///use std::time::Duration; + + ///let mut timer = Timer::from_seconds(1.0, TimerMode::Once); + + ///timer.tick(Duration::from_secs_f32(1.5)); + + ///assert!(timer.just_finished()); + + ///timer.tick(Duration::from_secs_f32(0.5)); + + ///assert!(!timer.just_finished()); + + ///``` + + #[lua( + + + + )] + fn just_finished ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns the time elapsed on the timer as an `f32`. + + ///See also [`Timer::elapsed`](Timer::elapsed). + + #[lua( + + + + )] + fn elapsed_secs ( + + + &self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Pauses the Timer. Disables the ticking of the timer. + /// - ///[generational index]: https://lucassardois.medium.com/generational-indices-guide-8e3c5f7fd594 + + ///See also [`Stopwatch::pause`](Stopwatch::pause). + /// - ///# Usage + + ///# Examples + + ///``` + + ///# use bevy_time::*; + + ///use std::time::Duration; + + ///let mut timer = Timer::from_seconds(1.0, TimerMode::Once); + + ///timer.pause(); + + ///timer.tick(Duration::from_secs_f32(0.5)); + + ///assert_eq!(timer.elapsed_secs(), 0.0); + + ///``` + + #[lua( + + + + )] + fn pause ( + + + &mut self, + + + ) + ; +"#, + r#" + + ///Unpauses the Timer. Resumes the ticking of the timer. + /// - ///This data type is returned by iterating a `Query` that has `Entity` as part of its query fetch type parameter ([learn more]). - ///It can also be obtained by calling [`EntityCommands::id`] or [`EntityMut::id`]. + + ///See also [`Stopwatch::unpause()`](Stopwatch::unpause). + /// + + ///# Examples + ///``` - ///# use bevy_ecs::prelude::*; - ///# #[derive(Component)] - ///# struct SomeComponent; - ///fn setup(mut commands: Commands) { - /// // Calling `spawn` returns `EntityCommands`. - /// let entity = commands.spawn(SomeComponent).id(); - ///} + + ///# use bevy_time::*; + + ///use std::time::Duration; + + ///let mut timer = Timer::from_seconds(1.0, TimerMode::Once); + + ///timer.pause(); + + ///timer.tick(Duration::from_secs_f32(0.5)); + + ///timer.unpause(); + + ///timer.tick(Duration::from_secs_f32(0.5)); + + ///assert_eq!(timer.elapsed_secs(), 0.5); + + ///``` + + #[lua( + + + + )] + fn unpause ( + + + &mut self, + + + ) + ; +"#, + r#" + + ///Returns `true` if the timer is paused. + /// - ///fn exclusive_system(world: &mut World) { - /// // Calling `spawn` returns `EntityMut`. - /// let entity = world.spawn(SomeComponent).id(); - ///} - ///# - ///# bevy_ecs::system::assert_is_system(setup); - ///# bevy_ecs::system::assert_is_system(exclusive_system); + + ///See also [`Stopwatch::paused`](Stopwatch::paused). + + /// + + ///# Examples + + ///``` + + ///# use bevy_time::*; + + ///let mut timer = Timer::from_seconds(1.0, TimerMode::Once); + + ///assert!(!timer.paused()); + + ///timer.pause(); + + ///assert!(timer.paused()); + + ///timer.unpause(); + + ///assert!(!timer.paused()); + ///``` + + #[lua( + + + + )] + fn paused ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Resets the timer. The reset doesn't affect the `paused` state of the timer. + /// - ///It can be used to refer to a specific entity to apply [`EntityCommands`], or to call [`Query::get`] (or similar methods) to access its components. + + ///See also [`Stopwatch::reset`](Stopwatch::reset). + /// + + ///Examples + ///``` - ///# use bevy_ecs::prelude::*; - ///# - ///# #[derive(Component)] - ///# struct Expired; - ///# - ///fn dispose_expired_food(mut commands: Commands, query: Query>) { - /// for food_entity in &query { - /// commands.entity(food_entity).despawn(); - /// } - ///} - ///# - ///# bevy_ecs::system::assert_is_system(dispose_expired_food); + + ///# use bevy_time::*; + + ///use std::time::Duration; + + ///let mut timer = Timer::from_seconds(1.0, TimerMode::Once); + + ///timer.tick(Duration::from_secs_f32(1.5)); + + ///timer.reset(); + + ///assert!(!timer.finished()); + + ///assert!(!timer.just_finished()); + + ///assert_eq!(timer.elapsed_secs(), 0.0); + ///``` + + #[lua( + + + + )] + fn reset ( + + + &mut self, + + + ) + ; +"#, + r#" + + ///Returns the percentage of the timer elapsed time (goes from 0.0 to 1.0). + /// - ///[learn more]: crate::system::Query#entity-id-access - ///[`EntityCommands::id`]: crate::system::EntityCommands::id - ///[`EntityMut::id`]: crate::world::EntityMut::id - ///[`EntityCommands`]: crate::system::EntityCommands - ///[`Query::get`]: crate::system::Query::get - ///[`World`]: crate::world::World - bevy_ecs::entity::Entity : - Clone + - Debug + - Methods - ( - ///Creates a new entity ID with the specified `index` and a generation of 0. - /// - ///# Note - /// - ///Spawning a specific `entity` value is __rarely the right choice__. Most apps should favor - ///[`Commands::spawn`](crate::system::Commands::spawn). This method should generally - ///only be used for sharing entities across apps, and only when they have a scheme - ///worked out to share an index space (which doesn't happen by default). - /// - ///In general, one should not try to synchronize the ECS by attempting to ensure that - ///`Entity` lines up between instances, but instead insert a secondary identifier as - ///a component. - from_raw(Raw(u32)) -> Wrapped(Entity), - - ///Convert to a form convenient for passing outside of rust. - /// - ///Only useful for identifying entities within the same instance of an application. Do not use - ///for serialization between runs. - /// - ///No particular structure is guaranteed for the returned bits. - to_bits(self:) -> Raw(u64), - - ///Reconstruct an `Entity` previously destructured with [`Entity::to_bits`]. - /// - ///Only useful when applied to results from `to_bits` in the same instance of an application. - from_bits(Raw(u64)) -> self, - - ///Return a transiently unique identifier. - /// - ///No two simultaneously-live entities share the same index, but dead entities' indices may collide - ///with both live and dead entities. Useful for compactly representing entities within a - ///specific snapshot of the world, such as when serializing. - index(self:) -> Raw(u32), - - ///Returns the generation of this Entity's index. The generation is incremented each time an - ///entity with a given index is despawned. This serves as a "count" of the number of times a - ///given index has been reused (index, generation) pairs uniquely identify a given Entity. - generation(self:) -> Raw(u32), - - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Describe the position of an entity. If the entity has a parent, the position is relative - ///to its parent position. + + ///# Examples + + ///``` + + ///# use bevy_time::*; + + ///use std::time::Duration; + + ///let mut timer = Timer::from_seconds(2.0, TimerMode::Once); + + ///timer.tick(Duration::from_secs_f32(0.5)); + + ///assert_eq!(timer.percent(), 0.25); + + ///``` + + #[lua( + + + + )] + fn percent ( + + + &self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns the percentage of the timer remaining time (goes from 1.0 to 0.0). + /// - ///* To place or move an entity, you should set its [`Transform`]. - ///* To get the global transform of an entity, you should get its [`GlobalTransform`]. - ///* To be displayed, an entity must have both a [`Transform`] and a [`GlobalTransform`]. - /// * You may use the [`TransformBundle`](crate::TransformBundle) to guarantee this. + + ///# Examples + + ///``` + + ///# use bevy_time::*; + + ///use std::time::Duration; + + ///let mut timer = Timer::from_seconds(2.0, TimerMode::Once); + + ///timer.tick(Duration::from_secs_f32(0.5)); + + ///assert_eq!(timer.percent_left(), 0.75); + + ///``` + + #[lua( + + + + )] + fn percent_left ( + + + &self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns the remaining time in seconds + /// - ///## [`Transform`] and [`GlobalTransform`] + + ///# Examples + + ///``` + + ///# use bevy_time::*; + + ///use std::cmp::Ordering; + + ///use std::time::Duration; + + ///let mut timer = Timer::from_seconds(2.0, TimerMode::Once); + + ///timer.tick(Duration::from_secs_f32(0.5)); + + ///let result = timer.remaining_secs().total_cmp(&1.5); + + ///assert_eq!(Ordering::Equal, result); + + ///``` + + #[lua( + + + + )] + fn remaining_secs ( + + + &self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns the number of times a repeating timer + + ///finished during the last [`tick`](Timer::tick) call. + /// - ///[`Transform`] is the position of an entity relative to its parent position, or the reference - ///frame if it doesn't have a [`Parent`](bevy_hierarchy::Parent). + + ///For non repeating-timers, this method will only ever + + ///return 0 or 1. + /// - ///[`GlobalTransform`] is the position of an entity relative to the reference frame. + + ///# Examples + + ///``` + + ///# use bevy_time::*; + + ///use std::time::Duration; + + ///let mut timer = Timer::from_seconds(1.0, TimerMode::Repeating); + + ///timer.tick(Duration::from_secs_f32(6.0)); + + ///assert_eq!(timer.times_finished_this_tick(), 6); + + ///timer.tick(Duration::from_secs_f32(2.0)); + + ///assert_eq!(timer.times_finished_this_tick(), 2); + + ///timer.tick(Duration::from_secs_f32(0.5)); + + ///assert_eq!(timer.times_finished_this_tick(), 0); + + ///``` + + #[lua( + + + + )] + fn times_finished_this_tick ( + + + &self, + + + ) + + + -> u32 + + ; +"#, + ] +)] +pub struct Timer; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::ecs::entity::Entity", + functions[r#" + + ///Creates a new entity ID with the specified `index` and a generation of 0. + /// - ///[`GlobalTransform`] is updated from [`Transform`] by systems in the system set - ///[`TransformPropagate`](crate::TransformSystem::TransformPropagate). + + ///# Note + /// - ///This system runs during [`PostUpdate`](bevy_app::PostUpdate). If you - ///update the [`Transform`] of an entity during this set or after, you will notice a 1 frame lag - ///before the [`GlobalTransform`] is updated. + + ///Spawning a specific `entity` value is __rarely the right choice__. Most apps should favor + + ///[`Commands::spawn`](crate::system::Commands::spawn). This method should generally + + ///only be used for sharing entities across apps, and only when they have a scheme + + ///worked out to share an index space (which doesn't happen by default). + /// - ///# Examples + + ///In general, one should not try to synchronize the ECS by attempting to ensure that + + ///`Entity` lines up between instances, but instead insert a secondary identifier as + + ///a component. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_raw ( + + + + index : u32, + + + + ) + + + -> bevy::ecs::entity::Entity + + ; +"#, + r#" + + ///Convert to a form convenient for passing outside of rust. + /// - ///- [`transform`] - ///- [`global_vs_local_translation`] - /// - ///[`global_vs_local_translation`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/global_vs_local_translation.rs - ///[`transform`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/transform.rs - ///[`Transform`]: super::Transform - bevy_transform::components::Transform : - Clone + - Debug + - Methods - ( - ///Creates a new [`Transform`] at the position `(x, y, z)`. In 2d, the `z` component - ///is used for z-ordering elements: higher `z`-value will be in front of lower - ///`z`-value. - from_xyz(Raw(f32),Raw(f32),Raw(f32)) -> self, - - ///Extracts the translation, rotation, and scale from `matrix`. It must be a 3d affine - ///transformation matrix. - from_matrix(Wrapped(Mat4)) -> self, - - ///Creates a new [`Transform`], with `translation`. Rotation will be 0 and scale 1 on - ///all axes. - from_translation(Wrapped(Vec3)) -> self, - - ///Creates a new [`Transform`], with `rotation`. Translation will be 0 and scale 1 on - ///all axes. - from_rotation(Wrapped(Quat)) -> self, - - ///Creates a new [`Transform`], with `scale`. Translation will be 0 and rotation 0 on - ///all axes. - from_scale(Wrapped(Vec3)) -> self, - - ///Returns this [`Transform`] with a new rotation so that [`Transform::forward`] - ///points towards the `target` position and [`Transform::up`] points towards `up`. - /// - ///In some cases it's not possible to construct a rotation. Another axis will be picked in those cases: - ///* if `target` is the same as the transform translation, `Vec3::Z` is used instead - ///* if `up` is zero, `Vec3::Y` is used instead - ///* if the resulting forward direction is parallel with `up`, an orthogonal vector is used as the "right" direction - looking_at(self:Wrapped(Vec3),Wrapped(Vec3)) -> self, - - ///Returns this [`Transform`] with a new rotation so that [`Transform::forward`] - ///points in the given `direction` and [`Transform::up`] points towards `up`. - /// - ///In some cases it's not possible to construct a rotation. Another axis will be picked in those cases: - ///* if `direction` is zero, `Vec3::Z` is used instead - ///* if `up` is zero, `Vec3::Y` is used instead - ///* if `direction` is parallel with `up`, an orthogonal vector is used as the "right" direction - looking_to(self:Wrapped(Vec3),Wrapped(Vec3)) -> self, - - ///Returns this [`Transform`] with a new translation. - with_translation(self:Wrapped(Vec3)) -> self, - - ///Returns this [`Transform`] with a new rotation. - with_rotation(self:Wrapped(Quat)) -> self, - - ///Returns this [`Transform`] with a new scale. - with_scale(self:Wrapped(Vec3)) -> self, - - ///Returns the 3d affine transformation matrix from this transforms translation, - ///rotation, and scale. - compute_matrix(&self:) -> Wrapped(Mat4), - - ///Returns the 3d affine transformation matrix from this transforms translation, - ///rotation, and scale. - compute_affine(&self:) -> Wrapped(Affine3A), - - ///Get the unit vector in the local `X` direction. - local_x(&self:) -> Wrapped(Vec3), - - ///Equivalent to [`-local_x()`][Transform::local_x()] - left(&self:) -> Wrapped(Vec3), - - ///Equivalent to [`local_x()`][Transform::local_x()] - right(&self:) -> Wrapped(Vec3), - - ///Get the unit vector in the local `Y` direction. - local_y(&self:) -> Wrapped(Vec3), - - ///Equivalent to [`local_y()`][Transform::local_y] - up(&self:) -> Wrapped(Vec3), - - ///Equivalent to [`-local_y()`][Transform::local_y] - down(&self:) -> Wrapped(Vec3), - - ///Get the unit vector in the local `Z` direction. - local_z(&self:) -> Wrapped(Vec3), - - ///Equivalent to [`-local_z()`][Transform::local_z] - forward(&self:) -> Wrapped(Vec3), - - ///Equivalent to [`local_z()`][Transform::local_z] - back(&self:) -> Wrapped(Vec3), - - ///Rotates this [`Transform`] by the given rotation. - /// - ///If this [`Transform`] has a parent, the `rotation` is relative to the rotation of the parent. - /// - ///# Examples - /// - ///- [`3d_rotation`] - /// - ///[`3d_rotation`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/3d_rotation.rs - rotate(&mut self:Wrapped(Quat)), - - ///Rotates this [`Transform`] around the given `axis` by `angle` (in radians). - /// - ///If this [`Transform`] has a parent, the `axis` is relative to the rotation of the parent. - rotate_axis(&mut self:Wrapped(Vec3),Raw(f32)), - - ///Rotates this [`Transform`] around the `X` axis by `angle` (in radians). - /// - ///If this [`Transform`] has a parent, the axis is relative to the rotation of the parent. - rotate_x(&mut self:Raw(f32)), - - ///Rotates this [`Transform`] around the `Y` axis by `angle` (in radians). - /// - ///If this [`Transform`] has a parent, the axis is relative to the rotation of the parent. - rotate_y(&mut self:Raw(f32)), - - ///Rotates this [`Transform`] around the `Z` axis by `angle` (in radians). - /// - ///If this [`Transform`] has a parent, the axis is relative to the rotation of the parent. - rotate_z(&mut self:Raw(f32)), - - ///Rotates this [`Transform`] by the given `rotation`. - /// - ///The `rotation` is relative to this [`Transform`]'s current rotation. - rotate_local(&mut self:Wrapped(Quat)), - - ///Rotates this [`Transform`] around its local `axis` by `angle` (in radians). - rotate_local_axis(&mut self:Wrapped(Vec3),Raw(f32)), - - ///Rotates this [`Transform`] around its local `X` axis by `angle` (in radians). - rotate_local_x(&mut self:Raw(f32)), - - ///Rotates this [`Transform`] around its local `Y` axis by `angle` (in radians). - rotate_local_y(&mut self:Raw(f32)), - - ///Rotates this [`Transform`] around its local `Z` axis by `angle` (in radians). - rotate_local_z(&mut self:Raw(f32)), - - ///Translates this [`Transform`] around a `point` in space. - /// - ///If this [`Transform`] has a parent, the `point` is relative to the [`Transform`] of the parent. - translate_around(&mut self:Wrapped(Vec3),Wrapped(Quat)), - - ///Rotates this [`Transform`] around a `point` in space. - /// - ///If this [`Transform`] has a parent, the `point` is relative to the [`Transform`] of the parent. - rotate_around(&mut self:Wrapped(Vec3),Wrapped(Quat)), - - ///Rotates this [`Transform`] so that [`Transform::forward`] points towards the `target` position, - ///and [`Transform::up`] points towards `up`. - /// - ///In some cases it's not possible to construct a rotation. Another axis will be picked in those cases: - ///* if `target` is the same as the transtorm translation, `Vec3::Z` is used instead - ///* if `up` is zero, `Vec3::Y` is used instead - ///* if the resulting forward direction is parallel with `up`, an orthogonal vector is used as the "right" direction - look_at(&mut self:Wrapped(Vec3),Wrapped(Vec3)), - - ///Rotates this [`Transform`] so that [`Transform::forward`] points in the given `direction` - ///and [`Transform::up`] points towards `up`. - /// - ///In some cases it's not possible to construct a rotation. Another axis will be picked in those cases: - ///* if `direction` is zero, `Vec3::NEG_Z` is used instead - ///* if `up` is zero, `Vec3::Y` is used instead - ///* if `direction` is parallel with `up`, an orthogonal vector is used as the "right" direction - look_to(&mut self:Wrapped(Vec3),Wrapped(Vec3)), - - ///Multiplies `self` with `transform` component by component, returning the - ///resulting [`Transform`] - mul_transform(&self:Wrapped(Transform)) -> self, - - ///Transforms the given `point`, applying scale, rotation and translation. - /// - ///If this [`Transform`] has a parent, this will transform a `point` that is - ///relative to the parent's [`Transform`] into one relative to this [`Transform`]. - /// - ///If this [`Transform`] does not have a parent, this will transform a `point` - ///that is in global space into one relative to this [`Transform`]. - /// - ///If you want to transform a `point` in global space to the local space of this [`Transform`], - ///consider using [`GlobalTransform::transform_point()`] instead. - transform_point(&self:Wrapped(Vec3)) -> Wrapped(Vec3), - - ) - + Fields - ( - /// Position of the entity. In 2d, the last value of the `Vec3` is used for z-ordering. - /// - /// See the [`translations`] example for usage. - /// - /// [`translations`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/translation.rs - translation: Wrapped(Vec3), - /// Rotation of the entity. - /// - /// See the [`3d_rotation`] example for usage. - /// - /// [`3d_rotation`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/3d_rotation.rs - rotation: Wrapped(Quat), - /// Scale of the entity. - /// - /// See the [`scale`] example for usage. - /// - /// [`scale`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/scale.rs - scale: Wrapped(Vec3), - ) - + BinOps - ( - self Mul Wrapped(Transform) -> Wrapped(Transform), - self Mul Wrapped(Vec3) -> Wrapped(Vec3), - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Describe the position of an entity relative to the reference frame. + + ///Only useful for identifying entities within the same instance of an application. Do not use + + ///for serialization between runs. + /// - ///* To place or move an entity, you should set its [`Transform`]. - ///* [`GlobalTransform`] is fully managed by bevy, you cannot mutate it, use - /// [`Transform`] instead. - ///* To get the global transform of an entity, you should get its [`GlobalTransform`]. - ///* For transform hierarchies to work correctly, you must have both a [`Transform`] and a [`GlobalTransform`]. - /// * You may use the [`TransformBundle`](crate::TransformBundle) to guarantee this. + + ///No particular structure is guaranteed for the returned bits. + + #[lua( + + + + )] + fn to_bits ( + + + self, + + + ) + + + -> u64 + + ; +"#, + r#" + + ///Reconstruct an `Entity` previously destructured with [`Entity::to_bits`]. + /// - ///## [`Transform`] and [`GlobalTransform`] + + ///Only useful when applied to results from `to_bits` in the same instance of an application. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_bits ( + + + + bits : u64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Return a transiently unique identifier. + /// - ///[`Transform`] is the position of an entity relative to its parent position, or the reference - ///frame if it doesn't have a [`Parent`](bevy_hierarchy::Parent). + + ///No two simultaneously-live entities share the same index, but dead entities' indices may collide + + ///with both live and dead entities. Useful for compactly representing entities within a + + ///specific snapshot of the world, such as when serializing. + + #[lua( + + + + )] + fn index ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Returns the generation of this Entity's index. The generation is incremented each time an + + ///entity with a given index is despawned. This serves as a "count" of the number of times a + + ///given index has been reused (index, generation) pairs uniquely identify a given Entity. + + #[lua( + + + + )] + fn generation ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::ecs::storage::SparseSetIndex", + + + )] + fn sparse_set_index ( + + + &self, + + + ) + + + -> usize + + ; +"#, + r#" + + #[lua( + + kind="function", + + + as_trait="bevy::ecs::storage::SparseSetIndex", + + + output(proxy), + + )] + fn get_sparse_set_index ( + + + + value : usize, + + + + ) + + + -> Self + + ; +"#, + ] +)] +pub struct Entity; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::transform::components::Transform", + functions[r#" + + ///Creates a new [`Transform`] at the position `(x, y, z)`. In 2d, the `z` component + + ///is used for z-ordering elements: higher `z`-value will be in front of lower + + ///`z`-value. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_xyz ( + + + + x : f32, + + + + + + y : f32, + + + + + + z : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Extracts the translation, rotation, and scale from `matrix`. It must be a 3d affine + + ///transformation matrix. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_matrix ( + + + + #[proxy] + + matrix : bevy::math::f32::Mat4, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a new [`Transform`], with `translation`. Rotation will be 0 and scale 1 on + + ///all axes. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_translation ( + + + + #[proxy] + + translation : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a new [`Transform`], with `rotation`. Translation will be 0 and scale 1 on + + ///all axes. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation ( + + + + #[proxy] + + rotation : bevy::math::f32::Quat, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a new [`Transform`], with `scale`. Translation will be 0 and rotation 0 on + + ///all axes. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_scale ( + + + + #[proxy] + + scale : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns this [`Transform`] with a new rotation so that [`Transform::forward`] + + ///points towards the `target` position and [`Transform::up`] points towards `up`. + /// - ///[`GlobalTransform`] is the position of an entity relative to the reference frame. + + ///In some cases it's not possible to construct a rotation. Another axis will be picked in those cases: + + ///* if `target` is the same as the transform translation, `Vec3::Z` is used instead + + ///* if `up` is zero, `Vec3::Y` is used instead + + ///* if the resulting forward direction is parallel with `up`, an orthogonal vector is used as the "right" direction + + #[lua( + + + + output(proxy), + + )] + fn looking_at ( + + + self, + + + + + #[proxy] + + target : bevy::math::f32::Vec3, + + + + + + #[proxy] + + up : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns this [`Transform`] with a new rotation so that [`Transform::forward`] + + ///points in the given `direction` and [`Transform::up`] points towards `up`. + /// - ///[`GlobalTransform`] is updated from [`Transform`] by systems in the system set - ///[`TransformPropagate`](crate::TransformSystem::TransformPropagate). + + ///In some cases it's not possible to construct a rotation. Another axis will be picked in those cases: + + ///* if `direction` is zero, `Vec3::Z` is used instead + + ///* if `up` is zero, `Vec3::Y` is used instead + + ///* if `direction` is parallel with `up`, an orthogonal vector is used as the "right" direction + + #[lua( + + + + output(proxy), + + )] + fn looking_to ( + + + self, + + + + + #[proxy] + + direction : bevy::math::f32::Vec3, + + + + + + #[proxy] + + up : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns this [`Transform`] with a new translation. + + #[lua( + + + + output(proxy), + + )] + fn with_translation ( + + + self, + + + + + #[proxy] + + translation : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns this [`Transform`] with a new rotation. + + #[lua( + + + + output(proxy), + + )] + fn with_rotation ( + + + self, + + + + + #[proxy] + + rotation : bevy::math::f32::Quat, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns this [`Transform`] with a new scale. + + #[lua( + + + + output(proxy), + + )] + fn with_scale ( + + + self, + + + + + #[proxy] + + scale : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the 3d affine transformation matrix from this transforms translation, + + ///rotation, and scale. + + #[lua( + + + + output(proxy), + + )] + fn compute_matrix ( + + + &self, + + + ) + + + -> bevy::math::f32::Mat4 + + ; +"#, + r#" + + ///Returns the 3d affine transformation matrix from this transforms translation, + + ///rotation, and scale. + + #[lua( + + + + output(proxy), + + )] + fn compute_affine ( + + + &self, + + + ) + + + -> bevy::math::f32::Affine3A + + ; +"#, + r#" + + ///Get the unit vector in the local `X` direction. + + #[lua( + + + + output(proxy), + + )] + fn local_x ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Equivalent to [`-local_x()`][Transform::local_x()] + + #[lua( + + + + output(proxy), + + )] + fn left ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Equivalent to [`local_x()`][Transform::local_x()] + + #[lua( + + + + output(proxy), + + )] + fn right ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Get the unit vector in the local `Y` direction. + + #[lua( + + + + output(proxy), + + )] + fn local_y ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Equivalent to [`local_y()`][Transform::local_y] + + #[lua( + + + + output(proxy), + + )] + fn up ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Equivalent to [`-local_y()`][Transform::local_y] + + #[lua( + + + + output(proxy), + + )] + fn down ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Get the unit vector in the local `Z` direction. + + #[lua( + + + + output(proxy), + + )] + fn local_z ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Equivalent to [`-local_z()`][Transform::local_z] + + #[lua( + + + + output(proxy), + + )] + fn forward ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Equivalent to [`local_z()`][Transform::local_z] + + #[lua( + + + + output(proxy), + + )] + fn back ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Rotates this [`Transform`] by the given rotation. + /// - ///This system runs during [`PostUpdate`](bevy_app::PostUpdate). If you - ///update the [`Transform`] of an entity in this schedule or after, you will notice a 1 frame lag - ///before the [`GlobalTransform`] is updated. + + ///If this [`Transform`] has a parent, the `rotation` is relative to the rotation of the parent. + /// + ///# Examples + /// - ///- [`transform`] + + ///- [`3d_rotation`] + /// - ///[`transform`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/transform.rs - bevy_transform::components::GlobalTransform : - Clone + - Debug + - Methods - ( - ///Returns the 3d affine transformation matrix as a [`Mat4`]. - compute_matrix(&self:) -> Wrapped(Mat4), - - ///Returns the 3d affine transformation matrix as an [`Affine3A`]. - affine(&self:) -> Wrapped(Affine3A), - - ///Returns the transformation as a [`Transform`]. - /// - ///The transform is expected to be non-degenerate and without shearing, or the output - ///will be invalid. - compute_transform(&self:) -> Wrapped(Transform), - - ///Returns the [`Transform`] `self` would have if it was a child of an entity - ///with the `parent` [`GlobalTransform`]. - /// - ///This is useful if you want to "reparent" an [`Entity`](bevy_ecs::entity::Entity). - ///Say you have an entity `e1` that you want to turn into a child of `e2`, - ///but you want `e1` to keep the same global transform, even after re-parenting. You would use: - /// - ///```rust - ///# use bevy_transform::prelude::{GlobalTransform, Transform}; - ///# use bevy_ecs::prelude::{Entity, Query, Component, Commands}; - ///# use bevy_hierarchy::{prelude::Parent, BuildChildren}; - ///#[derive(Component)] - ///struct ToReparent { - /// new_parent: Entity, - ///} - ///fn reparent_system( - /// mut commands: Commands, - /// mut targets: Query<(&mut Transform, Entity, &GlobalTransform, &ToReparent)>, - /// transforms: Query<&GlobalTransform>, - ///) { - /// for (mut transform, entity, initial, to_reparent) in targets.iter_mut() { - /// if let Ok(parent_transform) = transforms.get(to_reparent.new_parent) { - /// *transform = initial.reparented_to(parent_transform); - /// commands.entity(entity) - /// .remove::() - /// .set_parent(to_reparent.new_parent); - /// } - /// } - ///} - ///``` - /// - ///The transform is expected to be non-degenerate and without shearing, or the output - ///will be invalid. - reparented_to(&self:Wrapped(&GlobalTransform)) -> Wrapped(Transform), - - ///Return the local right vector (X). - right(&self:) -> Wrapped(Vec3), - - ///Return the local left vector (-X). - left(&self:) -> Wrapped(Vec3), - - ///Return the local up vector (Y). - up(&self:) -> Wrapped(Vec3), - - ///Return the local down vector (-Y). - down(&self:) -> Wrapped(Vec3), - - ///Return the local back vector (Z). - back(&self:) -> Wrapped(Vec3), - - ///Return the local forward vector (-Z). - forward(&self:) -> Wrapped(Vec3), - - ///Get the translation as a [`Vec3`]. - translation(&self:) -> Wrapped(Vec3), - - ///Get the translation as a [`Vec3A`]. - translation_vec3a(&self:) -> Wrapped(Vec3A), - - ///Get an upper bound of the radius from the given `extents`. - radius_vec3a(&self:Wrapped(Vec3A)) -> Raw(f32), - - ///Transforms the given `point`, applying shear, scale, rotation and translation. - /// - ///This moves `point` into the local space of this [`GlobalTransform`]. - transform_point(&self:Wrapped(Vec3)) -> Wrapped(Vec3), - - ///Multiplies `self` with `transform` component by component, returning the - ///resulting [`GlobalTransform`] - mul_transform(&self:Wrapped(Transform)) -> self, - - ) - + Fields - ( - ) - + BinOps - ( - self Mul Wrapped(Transform) -> Wrapped(GlobalTransform), - self Mul Wrapped(GlobalTransform) -> Wrapped(GlobalTransform), - self Mul Wrapped(Vec3) -> Wrapped(Vec3), - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///An ambient light, which lights the entire scene equally. - bevy_pbr::AmbientLight : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - color: Wrapped(Color), - /// A direct scale factor multiplied with `color` before being passed to the shader. - brightness: Raw(f32), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - bevy_pbr::CubemapVisibleEntities : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A Directional light. + + ///[`3d_rotation`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/3d_rotation.rs + + #[lua( + + + + )] + fn rotate ( + + + &mut self, + + + + + #[proxy] + + rotation : bevy::math::f32::Quat, + + + + ) + ; +"#, + r#" + + ///Rotates this [`Transform`] around the given `axis` by `angle` (in radians). + /// - ///Directional lights don't exist in reality but they are a good - ///approximation for light sources VERY far away, like the sun or - ///the moon. + + ///If this [`Transform`] has a parent, the `axis` is relative to the rotation of the parent. + + #[lua( + + + + )] + fn rotate_axis ( + + + &mut self, + + + + + #[proxy] + + axis : bevy::math::f32::Vec3, + + + + + + angle : f32, + + + + ) + ; +"#, + r#" + + ///Rotates this [`Transform`] around the `X` axis by `angle` (in radians). + /// - ///The light shines along the forward direction of the entity's transform. With a default transform - ///this would be along the negative-Z axis. + + ///If this [`Transform`] has a parent, the axis is relative to the rotation of the parent. + + #[lua( + + + + )] + fn rotate_x ( + + + &mut self, + + + + + angle : f32, + + + + ) + ; +"#, + r#" + + ///Rotates this [`Transform`] around the `Y` axis by `angle` (in radians). + /// - ///Valid values for `illuminance` are: + + ///If this [`Transform`] has a parent, the axis is relative to the rotation of the parent. + + #[lua( + + + + )] + fn rotate_y ( + + + &mut self, + + + + + angle : f32, + + + + ) + ; +"#, + r#" + + ///Rotates this [`Transform`] around the `Z` axis by `angle` (in radians). + /// - ///| Illuminance (lux) | Surfaces illuminated by | - ///|-------------------|------------------------------------------------| - ///| 0.0001 | Moonless, overcast night sky (starlight) | - ///| 0.002 | Moonless clear night sky with airglow | - ///| 0.05–0.3 | Full moon on a clear night | - ///| 3.4 | Dark limit of civil twilight under a clear sky | - ///| 20–50 | Public areas with dark surroundings | - ///| 50 | Family living room lights | - ///| 80 | Office building hallway/toilet lighting | - ///| 100 | Very dark overcast day | - ///| 150 | Train station platforms | - ///| 320–500 | Office lighting | - ///| 400 | Sunrise or sunset on a clear day. | - ///| 1000 | Overcast day; typical TV studio lighting | - ///| 10,000–25,000 | Full daylight (not direct sun) | - ///| 32,000–100,000 | Direct sunlight | + + ///If this [`Transform`] has a parent, the axis is relative to the rotation of the parent. + + #[lua( + + + + )] + fn rotate_z ( + + + &mut self, + + + + + angle : f32, + + + + ) + ; +"#, + r#" + + ///Rotates this [`Transform`] by the given `rotation`. + /// - ///Source: [Wikipedia](https://en.wikipedia.org/wiki/Lux) + + ///The `rotation` is relative to this [`Transform`]'s current rotation. + + #[lua( + + + + )] + fn rotate_local ( + + + &mut self, + + + + + #[proxy] + + rotation : bevy::math::f32::Quat, + + + + ) + ; +"#, + r#" + + ///Rotates this [`Transform`] around its local `axis` by `angle` (in radians). + + #[lua( + + + + )] + fn rotate_local_axis ( + + + &mut self, + + + + + #[proxy] + + axis : bevy::math::f32::Vec3, + + + + + + angle : f32, + + + + ) + ; +"#, + r#" + + ///Rotates this [`Transform`] around its local `X` axis by `angle` (in radians). + + #[lua( + + + + )] + fn rotate_local_x ( + + + &mut self, + + + + + angle : f32, + + + + ) + ; +"#, + r#" + + ///Rotates this [`Transform`] around its local `Y` axis by `angle` (in radians). + + #[lua( + + + + )] + fn rotate_local_y ( + + + &mut self, + + + + + angle : f32, + + + + ) + ; +"#, + r#" + + ///Rotates this [`Transform`] around its local `Z` axis by `angle` (in radians). + + #[lua( + + + + )] + fn rotate_local_z ( + + + &mut self, + + + + + angle : f32, + + + + ) + ; +"#, + r#" + + ///Translates this [`Transform`] around a `point` in space. + /// - ///## Shadows + + ///If this [`Transform`] has a parent, the `point` is relative to the [`Transform`] of the parent. + + #[lua( + + + + )] + fn translate_around ( + + + &mut self, + + + + + #[proxy] + + point : bevy::math::f32::Vec3, + + + + + + #[proxy] + + rotation : bevy::math::f32::Quat, + + + + ) + ; +"#, + r#" + + ///Rotates this [`Transform`] around a `point` in space. + /// - ///To enable shadows, set the `shadows_enabled` property to `true`. + + ///If this [`Transform`] has a parent, the `point` is relative to the [`Transform`] of the parent. + + #[lua( + + + + )] + fn rotate_around ( + + + &mut self, + + + + + #[proxy] + + point : bevy::math::f32::Vec3, + + + + + + #[proxy] + + rotation : bevy::math::f32::Quat, + + + + ) + ; +"#, + r#" + + ///Rotates this [`Transform`] so that [`Transform::forward`] points towards the `target` position, + + ///and [`Transform::up`] points towards `up`. + /// - ///Shadows are produced via [cascaded shadow maps](https://developer.download.nvidia.com/SDK/10.5/opengl/src/cascaded_shadow_maps/doc/cascaded_shadow_maps.pdf). + + ///In some cases it's not possible to construct a rotation. Another axis will be picked in those cases: + + ///* if `target` is the same as the transtorm translation, `Vec3::Z` is used instead + + ///* if `up` is zero, `Vec3::Y` is used instead + + ///* if the resulting forward direction is parallel with `up`, an orthogonal vector is used as the "right" direction + + #[lua( + + + + )] + fn look_at ( + + + &mut self, + + + + + #[proxy] + + target : bevy::math::f32::Vec3, + + + + + + #[proxy] + + up : bevy::math::f32::Vec3, + + + + ) + ; +"#, + r#" + + ///Rotates this [`Transform`] so that [`Transform::forward`] points in the given `direction` + + ///and [`Transform::up`] points towards `up`. + /// - ///To modify the cascade set up, such as the number of cascades or the maximum shadow distance, - ///change the [`CascadeShadowConfig`] component of the [`crate::bundle::DirectionalLightBundle`]. + + ///In some cases it's not possible to construct a rotation. Another axis will be picked in those cases: + + ///* if `direction` is zero, `Vec3::NEG_Z` is used instead + + ///* if `up` is zero, `Vec3::Y` is used instead + + ///* if `direction` is parallel with `up`, an orthogonal vector is used as the "right" direction + + #[lua( + + + + )] + fn look_to ( + + + &mut self, + + + + + #[proxy] + + direction : bevy::math::f32::Vec3, + + + + + + #[proxy] + + up : bevy::math::f32::Vec3, + + + + ) + ; +"#, + r#" + + ///Multiplies `self` with `transform` component by component, returning the + + ///resulting [`Transform`] + + #[lua( + + + + output(proxy), + + )] + fn mul_transform ( + + + &self, + + + + + #[proxy] + + transform : bevy::transform::components::Transform, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Transforms the given `point`, applying scale, rotation and translation. + /// - ///To control the resolution of the shadow maps, use the [`DirectionalLightShadowMap`] resource: + + ///If this [`Transform`] has a parent, this will transform a `point` that is + + ///relative to the parent's [`Transform`] into one relative to this [`Transform`]. + /// + + ///If this [`Transform`] does not have a parent, this will transform a `point` + + ///that is in global space into one relative to this [`Transform`]. + + /// + + ///If you want to transform a `point` in global space to the local space of this [`Transform`], + + ///consider using [`GlobalTransform::transform_point()`] instead. + + #[lua( + + + + output(proxy), + + )] + fn transform_point ( + + + &self, + + + + + #[proxy] + + point : bevy::math::f32::Vec3, + + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + ] +)] +pub struct Transform; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::transform::components::GlobalTransform", + functions[r#" + + ///Returns the 3d affine transformation matrix as a [`Mat4`]. + + #[lua( + + + + output(proxy), + + )] + fn compute_matrix ( + + + &self, + + + ) + + + -> bevy::math::f32::Mat4 + + ; +"#, + r#" + + ///Returns the 3d affine transformation matrix as an [`Affine3A`]. + + #[lua( + + + + output(proxy), + + )] + fn affine ( + + + &self, + + + ) + + + -> bevy::math::f32::Affine3A + + ; +"#, + r#" + + ///Returns the transformation as a [`Transform`]. + + /// + + ///The transform is expected to be non-degenerate and without shearing, or the output + + ///will be invalid. + + #[lua( + + + + output(proxy), + + )] + fn compute_transform ( + + + &self, + + + ) + + + -> bevy::transform::components::Transform + + ; +"#, + r#" + + ///Returns the [`Transform`] `self` would have if it was a child of an entity + + ///with the `parent` [`GlobalTransform`]. + + /// + + ///This is useful if you want to "reparent" an [`Entity`](bevy_ecs::entity::Entity). + + ///Say you have an entity `e1` that you want to turn into a child of `e2`, + + ///but you want `e1` to keep the same global transform, even after re-parenting. You would use: + + /// + + ///```rust + + ///# use bevy_transform::prelude::{GlobalTransform, Transform}; + + ///# use bevy_ecs::prelude::{Entity, Query, Component, Commands}; + + ///# use bevy_hierarchy::{prelude::Parent, BuildChildren}; + + ///#[derive(Component)] + + ///struct ToReparent { + + /// new_parent: Entity, + + ///} + + ///fn reparent_system( + + /// mut commands: Commands, + + /// mut targets: Query<(&mut Transform, Entity, &GlobalTransform, &ToReparent)>, + + /// transforms: Query<&GlobalTransform>, + + ///) { + + /// for (mut transform, entity, initial, to_reparent) in targets.iter_mut() { + + /// if let Ok(parent_transform) = transforms.get(to_reparent.new_parent) { + + /// *transform = initial.reparented_to(parent_transform); + + /// commands.entity(entity) + + /// .remove::() + + /// .set_parent(to_reparent.new_parent); + + /// } + + /// } + + ///} + ///``` - ///# use bevy_app::prelude::*; - ///# use bevy_pbr::DirectionalLightShadowMap; - ///App::new() - /// .insert_resource(DirectionalLightShadowMap { size: 2048 }); - ///``` - bevy_pbr::DirectionalLight : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - color: Wrapped(Color), - /// Illuminance in lux - illuminance: Raw(f32), - shadows_enabled: Raw(bool), - shadow_depth_bias: Raw(f32), - /// A bias applied along the direction of the fragment's surface normal. It is scaled to the - /// shadow map's texel size so that it is automatically adjusted to the orthographic projection. - shadow_normal_bias: Raw(f32), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Controls the resolution of [`DirectionalLight`] shadow maps. - bevy_pbr::DirectionalLightShadowMap : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - size: Raw(usize), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Add this component to make a [`Mesh`](bevy_render::mesh::Mesh) not cast shadows. - bevy_pbr::NotShadowCaster : - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Add this component to make a [`Mesh`](bevy_render::mesh::Mesh) not receive shadows. - bevy_pbr::NotShadowReceiver : - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A light that emits light in all directions from a central point. - /// - ///Real-world values for `intensity` (luminous power in lumens) based on the electrical power - ///consumption of the type of real-world light are: - /// - ///| Luminous Power (lumen) (i.e. the intensity member) | Incandescent non-halogen (Watts) | Incandescent halogen (Watts) | Compact fluorescent (Watts) | LED (Watts | - ///|------|-----|----|--------|-------| - ///| 200 | 25 | | 3-5 | 3 | - ///| 450 | 40 | 29 | 9-11 | 5-8 | - ///| 800 | 60 | | 13-15 | 8-12 | - ///| 1100 | 75 | 53 | 18-20 | 10-16 | - ///| 1600 | 100 | 72 | 24-28 | 14-17 | - ///| 2400 | 150 | | 30-52 | 24-30 | - ///| 3100 | 200 | | 49-75 | 32 | - ///| 4000 | 300 | | 75-100 | 40.5 | - /// - ///Source: [Wikipedia](https://en.wikipedia.org/wiki/Lumen_(unit)#Lighting) - bevy_pbr::PointLight : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - color: Wrapped(Color), - intensity: Raw(f32), - range: Raw(f32), - radius: Raw(f32), - shadows_enabled: Raw(bool), - shadow_depth_bias: Raw(f32), - /// A bias applied along the direction of the fragment's surface normal. It is scaled to the - /// shadow map's texel size so that it can be small close to the camera and gets larger further - /// away. - shadow_normal_bias: Raw(f32), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - bevy_pbr::PointLightShadowMap : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - size: Raw(usize), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Sets how a material's base color alpha channel is used for transparency. - bevy_pbr::AlphaMode : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Controls whether an entity should rendered in wireframe-mode if the [`WireframePlugin`] is enabled - bevy_pbr::wireframe::Wireframe : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - bevy_pbr::wireframe::WireframeConfig : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - /// Whether to show wireframes for all meshes. If `false`, only meshes with a [Wireframe] component will be rendered. - global: Raw(bool), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///The depth clear operation to perform for the main 3d pass. - bevy_core_pipeline::core_3d::Camera3dDepthLoadOp : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A [`Resource`] that stores the color that is used to clear the screen between frames. - /// - ///This color appears as the "background" color for simple apps, - ///when there are portions of the screen with nothing rendered. - bevy_core_pipeline::clear_color::ClearColor : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - bevy_core_pipeline::clear_color::ClearColorConfig : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - bevy_core_pipeline::core_2d::Camera2d : - Clone + - Methods - ( - ) - + Fields - ( - clear_color: Wrapped(ClearColorConfig), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Configuration for the "main 3d render graph". - bevy_core_pipeline::core_3d::Camera3d : - Clone + - Methods - ( - ) - + Fields - ( - /// The clear color operation to perform for the main 3d pass. - clear_color: Wrapped(ClearColorConfig), - /// The depth clear operation to perform for the main 3d pass. - depth_load_op: Wrapped(Camera3dDepthLoadOp), - /// The texture usages for the depth texture created for the main 3d pass. - depth_texture_usages: Raw(ReflectedValue), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///How a sprite is positioned relative to its [`Transform`](bevy_transform::components::Transform). - ///It defaults to `Anchor::Center`. - bevy_sprite::Anchor : - Clone + - Debug + - Methods - ( - as_vec(&self:) -> Wrapped(Vec2), - - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Component for rendering with meshes in the 2d pipeline, usually with a [2d material](crate::Material2d) such as [`ColorMaterial`](crate::ColorMaterial). - /// - ///It wraps a [`Handle`] to differentiate from the 3d pipelines which use the handles directly as components - bevy_sprite::Mesh2dHandle : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - bevy_sprite::TextureAtlasSprite : - Clone + - Debug + - Methods - ( - ///Create a new [`TextureAtlasSprite`] with a sprite index, - ///it should be valid in the corresponding [`TextureAtlas`] - new(Raw(usize)) -> Wrapped(TextureAtlasSprite), - - ) - + Fields - ( - /// The tint color used to draw the sprite, defaulting to [`Color::WHITE`] - color: Wrapped(Color), - /// Texture index in [`TextureAtlas`] - index: Raw(usize), - /// Whether to flip the sprite in the X axis - flip_x: Raw(bool), - /// Whether to flip the sprite in the Y axis - flip_y: Raw(bool), - /// An optional custom size for the sprite that will be used when rendering, instead of the size - /// of the sprite's image in the atlas - custom_size: Raw(ReflectedValue), - /// [`Anchor`] point of the sprite in the world - anchor: Wrapped(Anchor), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - bevy_sprite::Sprite : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - /// The sprite's color tint - color: Wrapped(Color), - /// Flip the sprite along the `X` axis - flip_x: Raw(bool), - /// Flip the sprite along the `Y` axis - flip_y: Raw(bool), - /// An optional custom size for the sprite that will be used when rendering, instead of the size - /// of the sprite's image - custom_size: Raw(ReflectedValue), - /// An optional rectangle representing the region of the sprite's image to render, instead of - /// rendering the full image. This is an easy one-off alternative to using a texture atlas. - rect: Raw(ReflectedValue), - /// [`Anchor`] point of the sprite in the world - anchor: Wrapped(Anchor), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Describes which rendering layers an entity belongs to. + /// - ///Cameras with this component will only render entities with intersecting - ///layers. + + ///The transform is expected to be non-degenerate and without shearing, or the output + + ///will be invalid. + + #[lua( + + + + output(proxy), + + )] + fn reparented_to ( + + + &self, + + + + + #[proxy] + + parent : &bevy::transform::components::GlobalTransform, + + + + ) + + + -> bevy::transform::components::Transform + + ; +"#, + r#" + + ///Return the local right vector (X). + + #[lua( + + + + output(proxy), + + )] + fn right ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Return the local left vector (-X). + + #[lua( + + + + output(proxy), + + )] + fn left ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Return the local up vector (Y). + + #[lua( + + + + output(proxy), + + )] + fn up ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Return the local down vector (-Y). + + #[lua( + + + + output(proxy), + + )] + fn down ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Return the local back vector (Z). + + #[lua( + + + + output(proxy), + + )] + fn back ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Return the local forward vector (-Z). + + #[lua( + + + + output(proxy), + + )] + fn forward ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Get the translation as a [`Vec3`]. + + #[lua( + + + + output(proxy), + + )] + fn translation ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Get the translation as a [`Vec3A`]. + + #[lua( + + + + output(proxy), + + )] + fn translation_vec3a ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + ///Get an upper bound of the radius from the given `extents`. + + #[lua( + + + + )] + fn radius_vec3a ( + + + &self, + + + + + #[proxy] + + extents : bevy::math::f32::Vec3A, + + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Transforms the given `point`, applying shear, scale, rotation and translation. + /// - ///There are 32 layers numbered `0` - [`TOTAL_LAYERS`](RenderLayers::TOTAL_LAYERS). Entities may - ///belong to one or more layers, or no layer at all. + + ///This moves `point` into the local space of this [`GlobalTransform`]. + + #[lua( + + + + output(proxy), + + )] + fn transform_point ( + + + &self, + + + + + #[proxy] + + point : bevy::math::f32::Vec3, + + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Multiplies `self` with `transform` component by component, returning the + + ///resulting [`GlobalTransform`] + + #[lua( + + + + output(proxy), + + )] + fn mul_transform ( + + + &self, + + + + + #[proxy] + + transform : bevy::transform::components::Transform, + + + + ) + + + -> Self + + ; +"#, + ] +)] +pub struct GlobalTransform; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::pbr::AmbientLight", functions[])] +pub struct AmbientLight; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::pbr::CubemapVisibleEntities", functions[])] +pub struct CubemapVisibleEntities; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::pbr::DirectionalLight", functions[])] +pub struct DirectionalLight; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::pbr::DirectionalLightShadowMap", + functions[] +)] +pub struct DirectionalLightShadowMap; +#[derive(LuaProxy)] +#[proxy(derive(), remote = "bevy::pbr::NotShadowCaster", functions[])] +pub struct NotShadowCaster; +#[derive(LuaProxy)] +#[proxy(derive(), remote = "bevy::pbr::NotShadowReceiver", functions[])] +pub struct NotShadowReceiver; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::pbr::PointLight", functions[])] +pub struct PointLight; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::pbr::PointLightShadowMap", functions[])] +pub struct PointLightShadowMap; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::pbr::AlphaMode", functions[])] +pub struct AlphaMode; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::pbr::wireframe::Wireframe", functions[])] +pub struct Wireframe; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::pbr::wireframe::WireframeConfig", + functions[] +)] +pub struct WireframeConfig; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::core_pipeline::core_3d::Camera3dDepthLoadOp", + functions[] +)] +pub struct Camera3dDepthLoadOp; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::core_pipeline::clear_color::ClearColor", + functions[] +)] +pub struct ClearColor; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::core_pipeline::clear_color::ClearColorConfig", + functions[] +)] +pub struct ClearColorConfig; +#[derive(LuaProxy)] +#[proxy(derive(clone), remote = "bevy::core_pipeline::core_2d::Camera2d", functions[])] +pub struct Camera2d; +#[derive(LuaProxy)] +#[proxy(derive(clone), remote = "bevy::core_pipeline::core_3d::Camera3d", functions[])] +pub struct Camera3d; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::sprite::Anchor", + functions[r#" + + #[lua( + + + + output(proxy), + + )] + fn as_vec ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + ] +)] +pub struct Anchor; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::sprite::Mesh2dHandle", functions[])] +pub struct Mesh2dHandle; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::sprite::TextureAtlasSprite", + functions[r#" + + ///Create a new [`TextureAtlasSprite`] with a sprite index, + + ///it should be valid in the corresponding [`TextureAtlas`] + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn new ( + + + + index : usize, + + + + ) + + + -> bevy::sprite::TextureAtlasSprite + + ; +"#, + ] +)] +pub struct TextureAtlasSprite; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::sprite::Sprite", functions[])] +pub struct Sprite; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::render::view::visibility::RenderLayers", + functions[r#" + + ///Create a new `RenderLayers` that belongs to all layers. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn all ( + + ) + + + -> Self + + ; +"#, + r#" + + ///Create a new `RenderLayers` that belongs to no layers. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn none ( + + ) + + + -> Self + + ; +"#, + r#" + + ///Determine if a `RenderLayers` intersects another. + /// - ///The [`Default`] instance of `RenderLayers` contains layer `0`, the first layer. + + ///`RenderLayers`s intersect if they share any common layers. + /// - ///An entity with this component without any layers is invisible. + + ///A `RenderLayers` with no layers will not match any other + + ///`RenderLayers`, even another with no layers. + + #[lua( + + + + )] + fn intersects ( + + + &self, + + + + + #[proxy] + + other : &bevy::render::view::visibility::RenderLayers, + + + + ) + + + -> bool + + ; +"#, + ] +)] +pub struct RenderLayers; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::render::view::visibility::Visibility", + functions[] +)] +pub struct Visibility; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::render::view::visibility::VisibleEntities", + functions[r#" + + #[lua( + + + + )] + fn len ( + + + &self, + + + ) + + + -> usize + + ; +"#, + r#" + + #[lua( + + + + )] + fn is_empty ( + + + &self, + + + ) + + + -> bool + + ; +"#, + ] +)] +pub struct VisibleEntities; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::render::view::visibility::ComputedVisibility", + functions[r#" + + ///Whether this entity is visible to something this frame. This is true if and only if [`Self::is_visible_in_hierarchy`] and [`Self::is_visible_in_view`] + + ///are true. This is the canonical method to call to determine if an entity should be drawn. + + ///This value is updated in [`PostUpdate`] by the [`VisibilitySystems::CheckVisibility`] system set. + + ///Reading it during [`Update`](bevy_app::Update) will yield the value from the previous frame. + + #[lua( + + + + )] + fn is_visible ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Whether this entity is visible in the entity hierarchy, which is determined by the [`Visibility`] component. + + ///This takes into account "visibility inheritance". If any of this entity's ancestors (see [`Parent`]) are hidden, this entity + + ///will be hidden as well. This value is updated in the [`VisibilitySystems::VisibilityPropagate`], which lives in the [`PostUpdate`] schedule. + + #[lua( + + + + )] + fn is_visible_in_hierarchy ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Whether this entity is visible in _any_ view (Cameras, Lights, etc). Each entity type (and view type) should choose how to set this + + ///value. For cameras and drawn entities, this will take into account [`RenderLayers`]. + /// - ///Entities without this component belong to layer `0`. - bevy_render::view::visibility::RenderLayers : - Clone + - Debug + - Methods - ( - ///Create a new `RenderLayers` that belongs to all layers. - all() -> self, - - ///Create a new `RenderLayers` that belongs to no layers. - none() -> self, - - ///Determine if a `RenderLayers` intersects another. - /// - ///`RenderLayers`s intersect if they share any common layers. - /// - ///A `RenderLayers` with no layers will not match any other - ///`RenderLayers`, even another with no layers. - intersects(&self:Wrapped(&RenderLayers)) -> Raw(bool), - - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///User indication of whether an entity is visible. Propagates down the entity hierarchy. - /// - ///If an entity is hidden in this way, all [`Children`] (and all of their children and so on) who - ///are set to [`Inherited`](Self::Inherited) will also be hidden. - /// - ///This is done by the `visibility_propagate_system` which uses the entity hierarchy and - ///`Visibility` to set the values of each entity's [`ComputedVisibility`] component. - bevy_render::view::visibility::Visibility : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Collection of entities visible from the current view. - /// - ///This component contains all entities which are visible from the currently - ///rendered view. The collection is updated automatically by the [`check_visibility()`] - ///system, and renderers can use it to optimize rendering of a particular view, to - ///prevent drawing items not visible from that view. - /// - ///This component is intended to be attached to the same entity as the [`Camera`] and - ///the [`Frustum`] defining the view. - /// - ///Currently this component is ignored by the sprite renderer, so sprite rendering - ///is not optimized per view. - bevy_render::view::visibility::VisibleEntities : - Clone + - Debug + - Methods - ( - len(&self:) -> Raw(usize), - - is_empty(&self:) -> Raw(bool), - - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering - bevy_render::view::visibility::ComputedVisibility : - Clone + - Debug + - Methods - ( - ///Whether this entity is visible to something this frame. This is true if and only if [`Self::is_visible_in_hierarchy`] and [`Self::is_visible_in_view`] - ///are true. This is the canonical method to call to determine if an entity should be drawn. - ///This value is updated in [`PostUpdate`] by the [`VisibilitySystems::CheckVisibility`] system set. - ///Reading it during [`Update`](bevy_app::Update) will yield the value from the previous frame. - is_visible(&self:) -> Raw(bool), - - ///Whether this entity is visible in the entity hierarchy, which is determined by the [`Visibility`] component. - ///This takes into account "visibility inheritance". If any of this entity's ancestors (see [`Parent`]) are hidden, this entity - ///will be hidden as well. This value is updated in the [`VisibilitySystems::VisibilityPropagate`], which lives in the [`PostUpdate`] schedule. - is_visible_in_hierarchy(&self:) -> Raw(bool), - - ///Whether this entity is visible in _any_ view (Cameras, Lights, etc). Each entity type (and view type) should choose how to set this - ///value. For cameras and drawn entities, this will take into account [`RenderLayers`]. - /// - ///This value is reset to `false` every frame in [`VisibilitySystems::VisibilityPropagate`] during [`PostUpdate`]. - ///Each entity type then chooses how to set this field in the [`VisibilitySystems::CheckVisibility`] system set, in [`PostUpdate`]. - ///Meshes might use frustum culling to decide if they are visible in a view. - ///Other entities might just set this to `true` every frame. - is_visible_in_view(&self:) -> Raw(bool), - - ///Sets `is_visible_in_view` to `true`. This is not reversible for a given frame, as it encodes whether or not this is visible in - ///_any_ view. This will be automatically reset to `false` every frame in [`VisibilitySystems::VisibilityPropagate`] and then set - ///to the proper value in [`VisibilitySystems::CheckVisibility`]. This should _only_ be set in systems with the [`VisibilitySystems::CheckVisibility`] - ///label. Don't call this unless you are defining a custom visibility system. For normal user-defined entity visibility, see [`Visibility`]. - set_visible_in_view(&mut self:), - - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - bevy_render::mesh::skinning::SkinnedMesh : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - inverse_bindposes: Raw(ReflectedValue), - joints: Raw(ReflectedValue), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - bevy_render::camera::ScalingMode : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - bevy_render::color::Color : - Clone + - Debug + - Methods - ( - ///New `Color` from sRGB colorspace. - /// - ///# Arguments - /// - ///* `r` - Red channel. [0.0, 1.0] - ///* `g` - Green channel. [0.0, 1.0] - ///* `b` - Blue channel. [0.0, 1.0] - /// - ///See also [`Color::rgba`], [`Color::rgb_u8`], [`Color::hex`]. - rgb(Raw(f32),Raw(f32),Raw(f32)) -> Wrapped(Color), - - ///New `Color` from sRGB colorspace. - /// - ///# Arguments - /// - ///* `r` - Red channel. [0.0, 1.0] - ///* `g` - Green channel. [0.0, 1.0] - ///* `b` - Blue channel. [0.0, 1.0] - ///* `a` - Alpha channel. [0.0, 1.0] - /// - ///See also [`Color::rgb`], [`Color::rgba_u8`], [`Color::hex`]. - rgba(Raw(f32),Raw(f32),Raw(f32),Raw(f32)) -> Wrapped(Color), - - ///New `Color` from linear RGB colorspace. - /// - ///# Arguments - /// - ///* `r` - Red channel. [0.0, 1.0] - ///* `g` - Green channel. [0.0, 1.0] - ///* `b` - Blue channel. [0.0, 1.0] - /// - ///See also [`Color::rgb`], [`Color::rgba_linear`]. - rgb_linear(Raw(f32),Raw(f32),Raw(f32)) -> Wrapped(Color), - - ///New `Color` from linear RGB colorspace. - /// - ///# Arguments - /// - ///* `r` - Red channel. [0.0, 1.0] - ///* `g` - Green channel. [0.0, 1.0] - ///* `b` - Blue channel. [0.0, 1.0] - ///* `a` - Alpha channel. [0.0, 1.0] - /// - ///See also [`Color::rgba`], [`Color::rgb_linear`]. - rgba_linear(Raw(f32),Raw(f32),Raw(f32),Raw(f32)) -> Wrapped(Color), - - ///New `Color` with HSL representation in sRGB colorspace. - /// - ///# Arguments - /// - ///* `hue` - Hue channel. [0.0, 360.0] - ///* `saturation` - Saturation channel. [0.0, 1.0] - ///* `lightness` - Lightness channel. [0.0, 1.0] - /// - ///See also [`Color::hsla`]. - hsl(Raw(f32),Raw(f32),Raw(f32)) -> Wrapped(Color), - - ///New `Color` with HSL representation in sRGB colorspace. - /// - ///# Arguments - /// - ///* `hue` - Hue channel. [0.0, 360.0] - ///* `saturation` - Saturation channel. [0.0, 1.0] - ///* `lightness` - Lightness channel. [0.0, 1.0] - ///* `alpha` - Alpha channel. [0.0, 1.0] - /// - ///See also [`Color::hsl`]. - hsla(Raw(f32),Raw(f32),Raw(f32),Raw(f32)) -> Wrapped(Color), - - ///New `Color` with LCH representation in sRGB colorspace. - /// - ///# Arguments - /// - ///* `lightness` - Lightness channel. [0.0, 1.5] - ///* `chroma` - Chroma channel. [0.0, 1.5] - ///* `hue` - Hue channel. [0.0, 360.0] - /// - ///See also [`Color::lcha`]. - lch(Raw(f32),Raw(f32),Raw(f32)) -> Wrapped(Color), - - ///New `Color` with LCH representation in sRGB colorspace. - /// - ///# Arguments - /// - ///* `lightness` - Lightness channel. [0.0, 1.5] - ///* `chroma` - Chroma channel. [0.0, 1.5] - ///* `hue` - Hue channel. [0.0, 360.0] - ///* `alpha` - Alpha channel. [0.0, 1.0] - /// - ///See also [`Color::lch`]. - lcha(Raw(f32),Raw(f32),Raw(f32),Raw(f32)) -> Wrapped(Color), - - ///New `Color` from sRGB colorspace. - /// - ///# Arguments - /// - ///* `r` - Red channel. [0, 255] - ///* `g` - Green channel. [0, 255] - ///* `b` - Blue channel. [0, 255] - /// - ///See also [`Color::rgb`], [`Color::rgba_u8`], [`Color::hex`]. - rgb_u8(Raw(u8),Raw(u8),Raw(u8)) -> Wrapped(Color), - - ///New `Color` from sRGB colorspace. - /// - ///# Arguments - /// - ///* `r` - Red channel. [0, 255] - ///* `g` - Green channel. [0, 255] - ///* `b` - Blue channel. [0, 255] - ///* `a` - Alpha channel. [0, 255] - /// - ///See also [`Color::rgba`], [`Color::rgb_u8`], [`Color::hex`]. - rgba_u8(Raw(u8),Raw(u8),Raw(u8),Raw(u8)) -> Wrapped(Color), - - ///Get red in sRGB colorspace. - r(&self:) -> Raw(f32), - - ///Get green in sRGB colorspace. - g(&self:) -> Raw(f32), - - ///Get blue in sRGB colorspace. - b(&self:) -> Raw(f32), - - ///Returns this color with red set to a new value in sRGB colorspace. - with_r(self:Raw(f32)) -> self, - - ///Returns this color with green set to a new value in sRGB colorspace. - with_g(self:Raw(f32)) -> self, - - ///Returns this color with blue set to a new value in sRGB colorspace. - with_b(self:Raw(f32)) -> self, - - ///Get alpha. - a(&self:) -> Raw(f32), - - ///Returns this color with a new alpha value. - with_a(self:Raw(f32)) -> self, - - ///Converts a `Color` to variant `Color::Rgba` - as_rgba(Wrapped(&Color):) -> Wrapped(Color), - - ///Converts a `Color` to variant `Color::RgbaLinear` - as_rgba_linear(Wrapped(&Color):) -> Wrapped(Color), - - ///Converts a `Color` to variant `Color::Hsla` - as_hsla(Wrapped(&Color):) -> Wrapped(Color), - - ///Converts a `Color` to variant `Color::Lcha` - as_lcha(Wrapped(&Color):) -> Wrapped(Color), - - ///Converts `Color` to a `u32` from sRGB colorspace. - /// - ///Maps the RGBA channels in RGBA order to a little-endian byte array (GPUs are little-endian). - ///`A` will be the most significant byte and `R` the least significant. - as_rgba_u32(Wrapped(Color):) -> Raw(u32), - - ///Converts Color to a u32 from linear RGB colorspace. - /// - ///Maps the RGBA channels in RGBA order to a little-endian byte array (GPUs are little-endian). - ///`A` will be the most significant byte and `R` the least significant. - as_linear_rgba_u32(Wrapped(Color):) -> Raw(u32), - - ) - + Fields - ( - ) - + BinOps - ( - self Add Wrapped(Vec4) -> Wrapped(Color), - self Add Wrapped(Color) -> Wrapped(Color), - self Mul Wrapped(Vec3) -> Wrapped(Color), - self Mul Raw(f32) -> Wrapped(Color), - self Mul Wrapped(Vec4) -> Wrapped(Color), - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///An axis-aligned bounding box. - bevy_render::primitives::Aabb : - Clone + - Debug + - Methods - ( - from_min_max(Wrapped(Vec3),Wrapped(Vec3)) -> self, - - min(&self:) -> Wrapped(Vec3A), - - max(&self:) -> Wrapped(Vec3A), - - ) - + Fields - ( - center: Wrapped(Vec3A), - half_extents: Wrapped(Vec3A), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - bevy_render::primitives::CubemapFrusta : - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A frustum made up of the 6 defining half spaces. - ///Half spaces are ordered left, right, top, bottom, near, far. - ///The normal vectors of the half spaces point towards the interior of the frustum. - bevy_render::primitives::Frustum : - Clone + - Debug + - Methods - ( - ///Returns a frustum derived from `view_projection`. - from_view_projection(Wrapped(&Mat4)) -> self, - - ///Returns a frustum derived from `view_projection`, - ///but with a custom far plane. - from_view_projection_custom_far(Wrapped(&Mat4),Wrapped(&Vec3),Wrapped(&Vec3),Raw(f32)) -> self, - - ///Checks if an Oriented Bounding Box (obb) intersects the frustum. - intersects_obb(&self:Wrapped(&Aabb),Wrapped(&Mat4),Raw(bool),Raw(bool)) -> Raw(bool), - - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Configuration resource for [Multi-Sample Anti-Aliasing](https://en.wikipedia.org/wiki/Multisample_anti-aliasing). + + ///This value is reset to `false` every frame in [`VisibilitySystems::VisibilityPropagate`] during [`PostUpdate`]. + + ///Each entity type then chooses how to set this field in the [`VisibilitySystems::CheckVisibility`] system set, in [`PostUpdate`]. + + ///Meshes might use frustum culling to decide if they are visible in a view. + + ///Other entities might just set this to `true` every frame. + + #[lua( + + + + )] + fn is_visible_in_view ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Sets `is_visible_in_view` to `true`. This is not reversible for a given frame, as it encodes whether or not this is visible in + + ///_any_ view. This will be automatically reset to `false` every frame in [`VisibilitySystems::VisibilityPropagate`] and then set + + ///to the proper value in [`VisibilitySystems::CheckVisibility`]. This should _only_ be set in systems with the [`VisibilitySystems::CheckVisibility`] + + ///label. Don't call this unless you are defining a custom visibility system. For normal user-defined entity visibility, see [`Visibility`]. + + #[lua( + + + + )] + fn set_visible_in_view ( + + + &mut self, + + + ) + ; +"#, + ] +)] +pub struct ComputedVisibility; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::render::mesh::skinning::SkinnedMesh", + functions[] +)] +pub struct SkinnedMesh; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::render::camera::ScalingMode", functions[])] +pub struct ScalingMode; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::render::color::Color", + functions[r#" + + ///New `Color` from sRGB colorspace. + /// - ///The number of samples to run for Multi-Sample Anti-Aliasing. Higher numbers result in - ///smoother edges. - ///Defaults to 4 samples. + + ///# Arguments + /// - ///Note that web currently only supports 1 or 4 samples. + + ///* `r` - Red channel. [0.0, 1.0] + + ///* `g` - Green channel. [0.0, 1.0] + + ///* `b` - Blue channel. [0.0, 1.0] + /// - ///# Example - ///``` - ///# use bevy_app::prelude::App; - ///# use bevy_render::prelude::Msaa; - ///App::new() - /// .insert_resource(Msaa::default()) - /// .run(); - ///``` - bevy_render::view::Msaa : - Clone + - Debug + - Methods - ( - samples(&self:) -> Raw(u32), - - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///The defining [`Component`] for camera entities, - ///storing information about how and what to render through this camera. - /// - ///The [`Camera`] component is added to an entity to define the properties of the viewpoint from - ///which rendering occurs. It defines the position of the view to render, the projection method - ///to transform the 3D objects into a 2D image, as well as the render target into which that image - ///is produced. - /// - ///Adding a camera is typically done by adding a bundle, either the `Camera2dBundle` or the - ///`Camera3dBundle`. - bevy_render::camera::Camera : - Clone + - Debug + - Methods - ( - ///The projection matrix computed using this camera's [`CameraProjection`]. - projection_matrix(&self:) -> Wrapped(Mat4), - - ) - + Fields - ( - /// If set, this camera will render to the given [`Viewport`] rectangle within the configured [`RenderTarget`]. - viewport: Raw(ReflectedValue), - /// Cameras with a higher order are rendered later, and thus on top of lower order cameras. - order: Raw(isize), - /// If this is set to `true`, this camera will be rendered to its specified [`RenderTarget`]. If `false`, this - /// camera will not be rendered. - is_active: Raw(bool), - /// The "target" that this camera will render to. - target: Wrapped(RenderTarget), - /// If this is set to `true`, the camera will use an intermediate "high dynamic range" render texture. - /// This allows rendering with a wider range of lighting values. - hdr: Raw(bool), - /// If this is enabled, a previous camera exists that shares this camera's render target, and this camera has MSAA enabled, then the previous camera's - /// outputs will be written to the intermediate multi-sampled render target textures for this camera. This enables cameras with MSAA enabled to - /// "write their results on top" of previous camera results, and include them as a part of their render results. This is enabled by default to ensure - /// cameras with MSAA enabled layer their results in the same way as cameras without MSAA enabled by default. - msaa_writeback: Raw(bool), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///The "target" that a [`Camera`] will render to. For example, this could be a [`Window`](bevy_window::Window) - ///swapchain or an [`Image`]. - bevy_render::camera::RenderTarget : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Render viewport configuration for the [`Camera`] component. - /// - ///The viewport defines the area on the render target to which the camera renders its image. - ///You can overlay multiple cameras in a single window using viewports to create effects like - ///split screen, minimaps, and character viewers. - bevy_render::camera::Viewport : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - /// The physical position to render this viewport to within the [`RenderTarget`] of this [`Camera`]. - /// (0,0) corresponds to the top-left corner - physical_position: Wrapped(UVec2), - /// The physical size of the viewport rectangle to render to within the [`RenderTarget`] of this [`Camera`]. - /// The origin of the rectangle is in the top-left corner. - physical_size: Wrapped(UVec2), - /// The minimum and maximum depth to render (on a scale from 0.0 to 1.0). - depth: Raw(ReflectedValue), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A configurable [`CameraProjection`] that can select its projection type at runtime. - bevy_render::camera::Projection : - Clone + - Debug + - Methods - ( - get_projection_matrix(&self:) -> Wrapped(Mat4), - - update(&mut self:Raw(f32),Raw(f32)), - - far(&self:) -> Raw(f32), - - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Project a 3D space onto a 2D surface using parallel lines, i.e., unlike [`PerspectiveProjection`], - ///the size of objects remains the same regardless of their distance to the camera. - /// - ///The volume contained in the projection is called the *view frustum*. Since the viewport is rectangular - ///and projection lines are parallel, the view frustum takes the shape of a cuboid. - /// - ///Note that the scale of the projection and the apparent size of objects are inversely proportional. - ///As the size of the projection increases, the size of objects decreases. - bevy_render::camera::OrthographicProjection : - Clone + - Debug + - Methods - ( - get_projection_matrix(&self:) -> Wrapped(Mat4), - - update(&mut self:Raw(f32),Raw(f32)), - - far(&self:) -> Raw(f32), - - ) - + Fields - ( - /// The distance of the near clipping plane in world units. - /// - /// Objects closer than this will not be rendered. - /// - /// Defaults to `0.0` - near: Raw(f32), - /// The distance of the far clipping plane in world units. - /// - /// Objects further than this will not be rendered. - /// - /// Defaults to `1000.0` - #[rename("_far")] - far: Raw(f32), - /// Specifies the origin of the viewport as a normalized position from 0 to 1, where (0, 0) is the bottom left - /// and (1, 1) is the top right. This determines where the camera's position sits inside the viewport. - /// - /// When the projection scales due to viewport resizing, the position of the camera, and thereby `viewport_origin`, - /// remains at the same relative point. - /// - /// Consequently, this is pivot point when scaling. With a bottom left pivot, the projection will expand - /// upwards and to the right. With a top right pivot, the projection will expand downwards and to the left. - /// Values in between will caused the projection to scale proportionally on each axis. - /// - /// Defaults to `(0.5, 0.5)`, which makes scaling affect opposite sides equally, keeping the center - /// point of the viewport centered. - viewport_origin: Wrapped(Vec2), - /// How the projection will scale when the viewport is resized. - /// - /// Defaults to `ScalingMode::WindowScale(1.0)` - scaling_mode: Wrapped(ScalingMode), - /// Scales the projection in world units. - /// - /// As scale increases, the apparent size of objects decreases, and vice versa. - /// - /// Defaults to `1.0` - scale: Raw(f32), - /// The area that the projection covers relative to `viewport_origin`. - /// - /// Bevy's [`camera_system`](crate::camera::camera_system) automatically - /// updates this value when the viewport is resized depending on `OrthographicProjection`'s other fields. - /// In this case, `area` should not be manually modified. - /// - /// It may be necessary to set this manually for shadow projections and such. - area: Wrapped(Rect), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 3D camera projection in which distant objects appear smaller than close objects. - bevy_render::camera::PerspectiveProjection : - Clone + - Debug + - Methods - ( - get_projection_matrix(&self:) -> Wrapped(Mat4), - - update(&mut self:Raw(f32),Raw(f32)), - - far(&self:) -> Raw(f32), - - ) - + Fields - ( - /// The vertical field of view (FOV) in radians. - /// - /// Defaults to a value of π/4 radians or 45 degrees. - fov: Raw(f32), - /// The aspect ratio (width divided by height) of the viewing frustum. - /// - /// Bevy's [`camera_system`](crate::camera::camera_system) automatically - /// updates this value when the aspect ratio of the associated window changes. - /// - /// Defaults to a value of `1.0`. - aspect_ratio: Raw(f32), - /// The distance from the camera in world units of the viewing frustum's near plane. - /// - /// Objects closer to the camera than this value will not be visible. - /// - /// Defaults to a value of `0.1`. - near: Raw(f32), - /// The distance from the camera in world units of the viewing frustum's far plane. - /// - /// Objects farther from the camera than this value will not be visible. - /// - /// Defaults to a value of `1000.0`. - #[rename("_far")] - far: Raw(f32), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Configures the [`RenderGraph`](crate::render_graph::RenderGraph) name assigned to be run for a given [`Camera`] entity. - bevy_render::camera::CameraRenderGraph : - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///An unique identifier to an asset path. - bevy_asset::AssetPathId : - Clone + - Debug + - Methods - ( - ///Gets the id of the source path. - source_path_id(&self:) -> Wrapped(SourcePathId), - - ///Gets the id of the sub-asset label. - label_id(&self:) -> Wrapped(LabelId), - - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///An unique identifier to a sub-asset label. - bevy_asset::LabelId : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///An unique identifier to the source path of an asset. - bevy_asset::SourcePathId : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A unique, stable asset id. - bevy_asset::HandleId : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 2-dimensional vector. - glam::f32::Vec2 : - Clone + - Debug + - Methods - ( - ///Creates a new vector. - new(Raw(f32),Raw(f32)) -> self, - - ///Creates a vector with all elements set to `v`. - splat(Raw(f32)) -> self, - - ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use - ///for each element of `self`. - /// - ///A true element in the mask uses the corresponding element from `if_true`, and false - ///uses the element from `if_false`. - select(Wrapped(BVec2),self,self) -> self, - - ///Creates a 3D vector from `self` and the given `z` value. - extend(self:Raw(f32)) -> Wrapped(Vec3), - - ///Computes the dot product of `self` and `rhs`. - dot(self:self) -> Raw(f32), - - ///Returns a vector where every component is the dot product of `self` and `rhs`. - dot_into_vec(self:self) -> self, - - ///Returns a vector containing the minimum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. - min(self:self) -> self, - - ///Returns a vector containing the maximum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. - max(self:self) -> self, - - ///Component-wise clamping of values, similar to [`f32::clamp`]. - /// - ///Each element in `min` must be less-or-equal to the corresponding element in `max`. - /// - ///# Panics - /// - ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. - clamp(self:self,self) -> self, - - ///Returns the horizontal minimum of `self`. - /// - ///In other words this computes `min(x, y, ..)`. - min_element(self:) -> Raw(f32), - - ///Returns the horizontal maximum of `self`. - /// - ///In other words this computes `max(x, y, ..)`. - max_element(self:) -> Raw(f32), - - ///Returns a vector mask containing the result of a `==` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all - ///elements. - cmpeq(self:self) -> Wrapped(BVec2), - - ///Returns a vector mask containing the result of a `!=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all - ///elements. - cmpne(self:self) -> Wrapped(BVec2), - - ///Returns a vector mask containing the result of a `>=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all - ///elements. - cmpge(self:self) -> Wrapped(BVec2), - - ///Returns a vector mask containing the result of a `>` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all - ///elements. - cmpgt(self:self) -> Wrapped(BVec2), - - ///Returns a vector mask containing the result of a `<=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all - ///elements. - cmple(self:self) -> Wrapped(BVec2), - - ///Returns a vector mask containing the result of a `<` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all - ///elements. - cmplt(self:self) -> Wrapped(BVec2), - - ///Returns a vector containing the absolute value of each element of `self`. - abs(self:) -> self, - - ///Returns a vector with elements representing the sign of `self`. - /// - ///- `1.0` if the number is positive, `+0.0` or `INFINITY` - ///- `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` - ///- `NAN` if the number is `NAN` - signum(self:) -> self, - - ///Returns a vector with signs of `rhs` and the magnitudes of `self`. - copysign(self:self) -> self, - - ///Returns a bitmask with the lowest 2 bits set to the sign bits from the elements of `self`. - /// - ///A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes - ///into the first lowest bit, element `y` into the second, etc. - is_negative_bitmask(self:) -> Raw(u32), - - ///Returns `true` if, and only if, all elements are finite. If any element is either - ///`NaN`, positive or negative infinity, this will return `false`. - is_finite(self:) -> Raw(bool), - - ///Returns `true` if any elements are `NaN`. - is_nan(self:) -> Raw(bool), - - ///Performs `is_nan` on each element of self, returning a vector mask of the results. - /// - ///In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. - is_nan_mask(self:) -> Wrapped(BVec2), - - ///Computes the length of `self`. - length(self:) -> Raw(f32), - - ///Computes the squared length of `self`. - /// - ///This is faster than `length()` as it avoids a square root operation. - length_squared(self:) -> Raw(f32), - - ///Computes `1.0 / length()`. - /// - ///For valid results, `self` must _not_ be of length zero. - length_recip(self:) -> Raw(f32), - - ///Computes the Euclidean distance between two points in space. - distance(self:self) -> Raw(f32), - - ///Compute the squared euclidean distance between two points in space. - distance_squared(self:self) -> Raw(f32), - - ///Returns `self` normalized to length 1.0. - /// - ///For valid results, `self` must _not_ be of length zero, nor very close to zero. - /// - ///See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. - /// - ///Panics - /// - ///Will panic if `self` is zero length when `glam_assert` is enabled. - normalize(self:) -> self, - - ///Returns `self` normalized to length 1.0 if possible, else returns zero. - /// - ///In particular, if the input is zero (or very close to zero), or non-finite, - ///the result of this operation will be zero. - /// - ///See also [`Self::try_normalize()`]. - normalize_or_zero(self:) -> self, - - ///Returns whether `self` is length `1.0` or not. - /// - ///Uses a precision threshold of `1e-6`. - is_normalized(self:) -> Raw(bool), - - ///Returns the vector projection of `self` onto `rhs`. - /// - ///`rhs` must be of non-zero length. - /// - ///# Panics - /// - ///Will panic if `rhs` is zero length when `glam_assert` is enabled. - project_onto(self:self) -> self, - - ///Returns the vector rejection of `self` from `rhs`. - /// - ///The vector rejection is the vector perpendicular to the projection of `self` onto - ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. - /// - ///`rhs` must be of non-zero length. - /// - ///# Panics - /// - ///Will panic if `rhs` has a length of zero when `glam_assert` is enabled. - reject_from(self:self) -> self, - - ///Returns the vector projection of `self` onto `rhs`. - /// - ///`rhs` must be normalized. - /// - ///# Panics - /// - ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. - project_onto_normalized(self:self) -> self, - - ///Returns the vector rejection of `self` from `rhs`. - /// - ///The vector rejection is the vector perpendicular to the projection of `self` onto - ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. - /// - ///`rhs` must be normalized. - /// - ///# Panics - /// - ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. - reject_from_normalized(self:self) -> self, - - ///Returns a vector containing the nearest integer to a number for each element of `self`. - ///Round half-way cases away from 0.0. - round(self:) -> self, - - ///Returns a vector containing the largest integer less than or equal to a number for each - ///element of `self`. - floor(self:) -> self, - - ///Returns a vector containing the smallest integer greater than or equal to a number for - ///each element of `self`. - ceil(self:) -> self, - - ///Returns a vector containing the integer part each element of `self`. This means numbers are - ///always truncated towards zero. - trunc(self:) -> self, - - ///Returns a vector containing the fractional part of the vector, e.g. `self - - ///self.floor()`. - /// - ///Note that this is fast but not precise for large numbers. - fract(self:) -> self, - - ///Returns a vector containing `e^self` (the exponential function) for each element of - ///`self`. - exp(self:) -> self, - - ///Returns a vector containing each element of `self` raised to the power of `n`. - powf(self:Raw(f32)) -> self, - - ///Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - recip(self:) -> self, - - ///Performs a linear interpolation between `self` and `rhs` based on the value `s`. - /// - ///When `s` is `0.0`, the result will be equal to `self`. When `s` is `1.0`, the result - ///will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly - ///extrapolated. - lerp(self:self,Raw(f32)) -> self, - - ///Returns true if the absolute difference of all elements between `self` and `rhs` is - ///less than or equal to `max_abs_diff`. - /// - ///This can be used to compare if two vectors contain similar elements. It works best when - ///comparing with a known value. The `max_abs_diff` that should be used used depends on - ///the values being compared against. - /// - ///For more see - ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - abs_diff_eq(self:self,Raw(f32)) -> Raw(bool), - - ///Returns a vector with a length no less than `min` and no more than `max` - /// - ///# Panics - /// - ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. - clamp_length(self:Raw(f32),Raw(f32)) -> self, - - ///Returns a vector with a length no more than `max` - clamp_length_max(self:Raw(f32)) -> self, - - ///Returns a vector with a length no less than `min` - clamp_length_min(self:Raw(f32)) -> self, - - ///Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding - ///error, yielding a more accurate result than an unfused multiply-add. - /// - ///Using `mul_add` *may* be more performant than an unfused multiply-add if the target - ///architecture has a dedicated fma CPU instruction. However, this is not always true, - ///and will be heavily dependant on designing algorithms with specific target hardware in - ///mind. - mul_add(self:self,self) -> self, - - ///Creates a 2D vector containing `[angle.cos(), angle.sin()]`. This can be used in - ///conjunction with the [`rotate()`][Self::rotate()] method, e.g. - ///`Vec2::from_angle(PI).rotate(Vec2::Y)` will create the vector `[-1, 0]` - ///and rotate [`Vec2::Y`] around it returning `-Vec2::Y`. - from_angle(Raw(f32)) -> self, - - ///Returns the angle (in radians) between `self` and `rhs` in the range `[-π, +π]`. - /// - ///The inputs do not need to be unit vectors however they must be non-zero. - angle_between(self:self) -> Raw(f32), - - ///Returns a vector that is equal to `self` rotated by 90 degrees. - perp(self:) -> self, - - ///The perpendicular dot product of `self` and `rhs`. - ///Also known as the wedge product, 2D cross product, and determinant. - perp_dot(self:self) -> Raw(f32), - - ///Returns `rhs` rotated by the angle of `self`. If `self` is normalized, - ///then this just rotation. This is what you usually want. Otherwise, - ///it will be like a rotation with a multiplication by `self`'s length. - rotate(self:self) -> self, - - ///Casts all elements of `self` to `f64`. - as_dvec2(&self:) -> Wrapped(DVec2), - - ///Casts all elements of `self` to `i32`. - as_ivec2(&self:) -> Wrapped(IVec2), - - ///Casts all elements of `self` to `u32`. - as_uvec2(&self:) -> Wrapped(UVec2), - - ) - + Fields - ( - x: Raw(f32), - y: Raw(f32), - ) - + BinOps - ( - self Add Raw(f32) -> Wrapped(Vec2), - self Add Wrapped(Vec2) -> Wrapped(Vec2), - self Add self -> Wrapped(Vec2), - self Sub Wrapped(Vec2) -> Wrapped(Vec2), - self Sub Raw(f32) -> Wrapped(Vec2), - self Sub self -> Wrapped(Vec2), - self Div Wrapped(Vec2) -> Wrapped(Vec2), - self Div Raw(f32) -> Wrapped(Vec2), - self Div self -> Wrapped(Vec2), - self Mul Raw(f32) -> Wrapped(Vec2), - self Mul Wrapped(Vec2) -> Wrapped(Vec2), - self Mul self -> Wrapped(Vec2), - self Rem self -> Wrapped(Vec2), - self Rem Raw(f32) -> Wrapped(Vec2), - self Rem Wrapped(Vec2) -> Wrapped(Vec2), - ) - + UnaryOps - ( - Neg self -> self - ) - lua impl - { - (MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}; - mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,f32)| {s.val_mut(|s| Ok(s[*idx] = val))?}; - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 3-dimensional vector. - glam::f32::Vec3 : - Clone + - Debug + - Methods - ( - ///Creates a new vector. - new(Raw(f32),Raw(f32),Raw(f32)) -> self, - - ///Creates a vector with all elements set to `v`. - splat(Raw(f32)) -> self, - - ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use - ///for each element of `self`. - /// - ///A true element in the mask uses the corresponding element from `if_true`, and false - ///uses the element from `if_false`. - select(Wrapped(BVec3),self,self) -> self, - - ///Creates a 4D vector from `self` and the given `w` value. - extend(self:Raw(f32)) -> Wrapped(Vec4), - - ///Creates a 2D vector from the `x` and `y` elements of `self`, discarding `z`. - /// - ///Truncation may also be performed by using [`self.xy()`][crate::swizzles::Vec3Swizzles::xy()]. - truncate(self:) -> Wrapped(Vec2), - - ///Computes the dot product of `self` and `rhs`. - dot(self:self) -> Raw(f32), - - ///Returns a vector where every component is the dot product of `self` and `rhs`. - dot_into_vec(self:self) -> self, - - ///Computes the cross product of `self` and `rhs`. - cross(self:self) -> self, - - ///Returns a vector containing the minimum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. - min(self:self) -> self, - - ///Returns a vector containing the maximum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. - max(self:self) -> self, - - ///Component-wise clamping of values, similar to [`f32::clamp`]. - /// - ///Each element in `min` must be less-or-equal to the corresponding element in `max`. - /// - ///# Panics - /// - ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. - clamp(self:self,self) -> self, - - ///Returns the horizontal minimum of `self`. - /// - ///In other words this computes `min(x, y, ..)`. - min_element(self:) -> Raw(f32), - - ///Returns the horizontal maximum of `self`. - /// - ///In other words this computes `max(x, y, ..)`. - max_element(self:) -> Raw(f32), - - ///Returns a vector mask containing the result of a `==` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all - ///elements. - cmpeq(self:self) -> Wrapped(BVec3), - - ///Returns a vector mask containing the result of a `!=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all - ///elements. - cmpne(self:self) -> Wrapped(BVec3), - - ///Returns a vector mask containing the result of a `>=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all - ///elements. - cmpge(self:self) -> Wrapped(BVec3), - - ///Returns a vector mask containing the result of a `>` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all - ///elements. - cmpgt(self:self) -> Wrapped(BVec3), - - ///Returns a vector mask containing the result of a `<=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all - ///elements. - cmple(self:self) -> Wrapped(BVec3), - - ///Returns a vector mask containing the result of a `<` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all - ///elements. - cmplt(self:self) -> Wrapped(BVec3), - - ///Returns a vector containing the absolute value of each element of `self`. - abs(self:) -> self, - - ///Returns a vector with elements representing the sign of `self`. - /// - ///- `1.0` if the number is positive, `+0.0` or `INFINITY` - ///- `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` - ///- `NAN` if the number is `NAN` - signum(self:) -> self, - - ///Returns a vector with signs of `rhs` and the magnitudes of `self`. - copysign(self:self) -> self, - - ///Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of `self`. - /// - ///A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes - ///into the first lowest bit, element `y` into the second, etc. - is_negative_bitmask(self:) -> Raw(u32), - - ///Returns `true` if, and only if, all elements are finite. If any element is either - ///`NaN`, positive or negative infinity, this will return `false`. - is_finite(self:) -> Raw(bool), - - ///Returns `true` if any elements are `NaN`. - is_nan(self:) -> Raw(bool), - - ///Performs `is_nan` on each element of self, returning a vector mask of the results. - /// - ///In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. - is_nan_mask(self:) -> Wrapped(BVec3), - - ///Computes the length of `self`. - length(self:) -> Raw(f32), - - ///Computes the squared length of `self`. - /// - ///This is faster than `length()` as it avoids a square root operation. - length_squared(self:) -> Raw(f32), - - ///Computes `1.0 / length()`. - /// - ///For valid results, `self` must _not_ be of length zero. - length_recip(self:) -> Raw(f32), - - ///Computes the Euclidean distance between two points in space. - distance(self:self) -> Raw(f32), - - ///Compute the squared euclidean distance between two points in space. - distance_squared(self:self) -> Raw(f32), - - ///Returns `self` normalized to length 1.0. - /// - ///For valid results, `self` must _not_ be of length zero, nor very close to zero. - /// - ///See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. - /// - ///Panics - /// - ///Will panic if `self` is zero length when `glam_assert` is enabled. - normalize(self:) -> self, - - ///Returns `self` normalized to length 1.0 if possible, else returns zero. - /// - ///In particular, if the input is zero (or very close to zero), or non-finite, - ///the result of this operation will be zero. - /// - ///See also [`Self::try_normalize()`]. - normalize_or_zero(self:) -> self, - - ///Returns whether `self` is length `1.0` or not. - /// - ///Uses a precision threshold of `1e-6`. - is_normalized(self:) -> Raw(bool), - - ///Returns the vector projection of `self` onto `rhs`. - /// - ///`rhs` must be of non-zero length. - /// - ///# Panics - /// - ///Will panic if `rhs` is zero length when `glam_assert` is enabled. - project_onto(self:self) -> self, - - ///Returns the vector rejection of `self` from `rhs`. - /// - ///The vector rejection is the vector perpendicular to the projection of `self` onto - ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. - /// - ///`rhs` must be of non-zero length. - /// - ///# Panics - /// - ///Will panic if `rhs` has a length of zero when `glam_assert` is enabled. - reject_from(self:self) -> self, - - ///Returns the vector projection of `self` onto `rhs`. - /// - ///`rhs` must be normalized. - /// - ///# Panics - /// - ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. - project_onto_normalized(self:self) -> self, - - ///Returns the vector rejection of `self` from `rhs`. - /// - ///The vector rejection is the vector perpendicular to the projection of `self` onto - ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. - /// - ///`rhs` must be normalized. - /// - ///# Panics - /// - ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. - reject_from_normalized(self:self) -> self, - - ///Returns a vector containing the nearest integer to a number for each element of `self`. - ///Round half-way cases away from 0.0. - round(self:) -> self, - - ///Returns a vector containing the largest integer less than or equal to a number for each - ///element of `self`. - floor(self:) -> self, - - ///Returns a vector containing the smallest integer greater than or equal to a number for - ///each element of `self`. - ceil(self:) -> self, - - ///Returns a vector containing the integer part each element of `self`. This means numbers are - ///always truncated towards zero. - trunc(self:) -> self, - - ///Returns a vector containing the fractional part of the vector, e.g. `self - - ///self.floor()`. - /// - ///Note that this is fast but not precise for large numbers. - fract(self:) -> self, - - ///Returns a vector containing `e^self` (the exponential function) for each element of - ///`self`. - exp(self:) -> self, - - ///Returns a vector containing each element of `self` raised to the power of `n`. - powf(self:Raw(f32)) -> self, - - ///Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - recip(self:) -> self, - - ///Performs a linear interpolation between `self` and `rhs` based on the value `s`. - /// - ///When `s` is `0.0`, the result will be equal to `self`. When `s` is `1.0`, the result - ///will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly - ///extrapolated. - lerp(self:self,Raw(f32)) -> self, - - ///Returns true if the absolute difference of all elements between `self` and `rhs` is - ///less than or equal to `max_abs_diff`. - /// - ///This can be used to compare if two vectors contain similar elements. It works best when - ///comparing with a known value. The `max_abs_diff` that should be used used depends on - ///the values being compared against. - /// - ///For more see - ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - abs_diff_eq(self:self,Raw(f32)) -> Raw(bool), - - ///Returns a vector with a length no less than `min` and no more than `max` - /// - ///# Panics - /// - ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. - clamp_length(self:Raw(f32),Raw(f32)) -> self, - - ///Returns a vector with a length no more than `max` - clamp_length_max(self:Raw(f32)) -> self, - - ///Returns a vector with a length no less than `min` - clamp_length_min(self:Raw(f32)) -> self, - - ///Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding - ///error, yielding a more accurate result than an unfused multiply-add. - /// - ///Using `mul_add` *may* be more performant than an unfused multiply-add if the target - ///architecture has a dedicated fma CPU instruction. However, this is not always true, - ///and will be heavily dependant on designing algorithms with specific target hardware in - ///mind. - mul_add(self:self,self) -> self, - - ///Returns the angle (in radians) between two vectors. - /// - ///The inputs do not need to be unit vectors however they must be non-zero. - angle_between(self:self) -> Raw(f32), - - ///Returns some vector that is orthogonal to the given one. - /// - ///The input vector must be finite and non-zero. - /// - ///The output vector is not necessarily unit length. For that use - ///[`Self::any_orthonormal_vector()`] instead. - any_orthogonal_vector(&self:) -> self, - - ///Returns any unit vector that is orthogonal to the given one. - /// - ///The input vector must be unit length. - /// - ///# Panics - /// - ///Will panic if `self` is not normalized when `glam_assert` is enabled. - any_orthonormal_vector(&self:) -> self, - - ///Casts all elements of `self` to `f64`. - as_dvec3(&self:) -> Wrapped(DVec3), - - ///Casts all elements of `self` to `i32`. - as_ivec3(&self:) -> Wrapped(IVec3), - - ///Casts all elements of `self` to `u32`. - as_uvec3(&self:) -> Wrapped(UVec3), - - ) - + Fields - ( - x: Raw(f32), - y: Raw(f32), - z: Raw(f32), - ) - + BinOps - ( - self Add self -> Wrapped(Vec3), - self Add Wrapped(Vec3) -> Wrapped(Vec3), - self Add Raw(f32) -> Wrapped(Vec3), - self Sub Raw(f32) -> Wrapped(Vec3), - self Sub self -> Wrapped(Vec3), - self Sub Wrapped(Vec3) -> Wrapped(Vec3), - self Div Wrapped(Vec3) -> Wrapped(Vec3), - self Div Raw(f32) -> Wrapped(Vec3), - self Div self -> Wrapped(Vec3), - self Mul self -> Wrapped(Vec3), - self Mul Wrapped(Vec3) -> Wrapped(Vec3), - self Mul Raw(f32) -> Wrapped(Vec3), - self Rem self -> Wrapped(Vec3), - self Rem Wrapped(Vec3) -> Wrapped(Vec3), - self Rem Raw(f32) -> Wrapped(Vec3), - ) - + UnaryOps - ( - Neg self -> self - ) - lua impl - { - (MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}; - mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,f32)| {s.val_mut(|s| Ok(s[*idx] = val))?}; - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 3-dimensional vector. - /// - ///SIMD vector types are used for storage on supported platforms for better - ///performance than the [`Vec3`] type. - /// - ///It is possible to convert between [`Vec3`] and [`Vec3A`] types using [`From`] - ///or [`Into`] trait implementations. - /// - ///This type is 16 byte aligned. - glam::f32::Vec3A : - Clone + - Debug + - Methods - ( - ///Creates a new vector. - new(Raw(f32),Raw(f32),Raw(f32)) -> self, - - ///Creates a vector with all elements set to `v`. - splat(Raw(f32)) -> self, - - ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use - ///for each element of `self`. - /// - ///A true element in the mask uses the corresponding element from `if_true`, and false - ///uses the element from `if_false`. - select(Wrapped(BVec3A),self,self) -> self, - - ///Creates a 4D vector from `self` and the given `w` value. - extend(self:Raw(f32)) -> Wrapped(Vec4), - - ///Creates a 2D vector from the `x` and `y` elements of `self`, discarding `z`. - /// - ///Truncation may also be performed by using [`self.xy()`][crate::swizzles::Vec3Swizzles::xy()]. - truncate(self:) -> Wrapped(Vec2), - - ///Computes the dot product of `self` and `rhs`. - dot(self:self) -> Raw(f32), - - ///Returns a vector where every component is the dot product of `self` and `rhs`. - dot_into_vec(self:self) -> self, - - ///Computes the cross product of `self` and `rhs`. - cross(self:self) -> self, - - ///Returns a vector containing the minimum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. - min(self:self) -> self, - - ///Returns a vector containing the maximum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. - max(self:self) -> self, - - ///Component-wise clamping of values, similar to [`f32::clamp`]. - /// - ///Each element in `min` must be less-or-equal to the corresponding element in `max`. - /// - ///# Panics - /// - ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. - clamp(self:self,self) -> self, - - ///Returns the horizontal minimum of `self`. - /// - ///In other words this computes `min(x, y, ..)`. - min_element(self:) -> Raw(f32), - - ///Returns the horizontal maximum of `self`. - /// - ///In other words this computes `max(x, y, ..)`. - max_element(self:) -> Raw(f32), - - ///Returns a vector mask containing the result of a `==` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all - ///elements. - cmpeq(self:self) -> Wrapped(BVec3A), - - ///Returns a vector mask containing the result of a `!=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all - ///elements. - cmpne(self:self) -> Wrapped(BVec3A), - - ///Returns a vector mask containing the result of a `>=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all - ///elements. - cmpge(self:self) -> Wrapped(BVec3A), - - ///Returns a vector mask containing the result of a `>` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all - ///elements. - cmpgt(self:self) -> Wrapped(BVec3A), - - ///Returns a vector mask containing the result of a `<=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all - ///elements. - cmple(self:self) -> Wrapped(BVec3A), - - ///Returns a vector mask containing the result of a `<` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all - ///elements. - cmplt(self:self) -> Wrapped(BVec3A), - - ///Returns a vector containing the absolute value of each element of `self`. - abs(self:) -> self, - - ///Returns a vector with elements representing the sign of `self`. - /// - ///- `1.0` if the number is positive, `+0.0` or `INFINITY` - ///- `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` - ///- `NAN` if the number is `NAN` - signum(self:) -> self, - - ///Returns a vector with signs of `rhs` and the magnitudes of `self`. - copysign(self:self) -> self, - - ///Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of `self`. - /// - ///A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes - ///into the first lowest bit, element `y` into the second, etc. - is_negative_bitmask(self:) -> Raw(u32), - - ///Returns `true` if, and only if, all elements are finite. If any element is either - ///`NaN`, positive or negative infinity, this will return `false`. - is_finite(self:) -> Raw(bool), - - ///Returns `true` if any elements are `NaN`. - is_nan(self:) -> Raw(bool), - - ///Performs `is_nan` on each element of self, returning a vector mask of the results. - /// - ///In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. - is_nan_mask(self:) -> Wrapped(BVec3A), - - ///Computes the length of `self`. - length(self:) -> Raw(f32), - - ///Computes the squared length of `self`. - /// - ///This is faster than `length()` as it avoids a square root operation. - length_squared(self:) -> Raw(f32), - - ///Computes `1.0 / length()`. - /// - ///For valid results, `self` must _not_ be of length zero. - length_recip(self:) -> Raw(f32), - - ///Computes the Euclidean distance between two points in space. - distance(self:self) -> Raw(f32), - - ///Compute the squared euclidean distance between two points in space. - distance_squared(self:self) -> Raw(f32), - - ///Returns `self` normalized to length 1.0. - /// - ///For valid results, `self` must _not_ be of length zero, nor very close to zero. - /// - ///See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. - /// - ///Panics - /// - ///Will panic if `self` is zero length when `glam_assert` is enabled. - normalize(self:) -> self, - - ///Returns `self` normalized to length 1.0 if possible, else returns zero. - /// - ///In particular, if the input is zero (or very close to zero), or non-finite, - ///the result of this operation will be zero. - /// - ///See also [`Self::try_normalize()`]. - normalize_or_zero(self:) -> self, - - ///Returns whether `self` is length `1.0` or not. - /// - ///Uses a precision threshold of `1e-6`. - is_normalized(self:) -> Raw(bool), - - ///Returns the vector projection of `self` onto `rhs`. - /// - ///`rhs` must be of non-zero length. - /// - ///# Panics - /// - ///Will panic if `rhs` is zero length when `glam_assert` is enabled. - project_onto(self:self) -> self, - - ///Returns the vector rejection of `self` from `rhs`. - /// - ///The vector rejection is the vector perpendicular to the projection of `self` onto - ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. - /// - ///`rhs` must be of non-zero length. - /// - ///# Panics - /// - ///Will panic if `rhs` has a length of zero when `glam_assert` is enabled. - reject_from(self:self) -> self, - - ///Returns the vector projection of `self` onto `rhs`. - /// - ///`rhs` must be normalized. - /// - ///# Panics - /// - ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. - project_onto_normalized(self:self) -> self, - - ///Returns the vector rejection of `self` from `rhs`. - /// - ///The vector rejection is the vector perpendicular to the projection of `self` onto - ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. - /// - ///`rhs` must be normalized. - /// - ///# Panics - /// - ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. - reject_from_normalized(self:self) -> self, - - ///Returns a vector containing the nearest integer to a number for each element of `self`. - ///Round half-way cases away from 0.0. - round(self:) -> self, - - ///Returns a vector containing the largest integer less than or equal to a number for each - ///element of `self`. - floor(self:) -> self, - - ///Returns a vector containing the smallest integer greater than or equal to a number for - ///each element of `self`. - ceil(self:) -> self, - - ///Returns a vector containing the integer part each element of `self`. This means numbers are - ///always truncated towards zero. - trunc(self:) -> self, - - ///Returns a vector containing the fractional part of the vector, e.g. `self - - ///self.floor()`. - /// - ///Note that this is fast but not precise for large numbers. - fract(self:) -> self, - - ///Returns a vector containing `e^self` (the exponential function) for each element of - ///`self`. - exp(self:) -> self, - - ///Returns a vector containing each element of `self` raised to the power of `n`. - powf(self:Raw(f32)) -> self, - - ///Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - recip(self:) -> self, - - ///Performs a linear interpolation between `self` and `rhs` based on the value `s`. - /// - ///When `s` is `0.0`, the result will be equal to `self`. When `s` is `1.0`, the result - ///will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly - ///extrapolated. - lerp(self:self,Raw(f32)) -> self, - - ///Returns true if the absolute difference of all elements between `self` and `rhs` is - ///less than or equal to `max_abs_diff`. - /// - ///This can be used to compare if two vectors contain similar elements. It works best when - ///comparing with a known value. The `max_abs_diff` that should be used used depends on - ///the values being compared against. - /// - ///For more see - ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - abs_diff_eq(self:self,Raw(f32)) -> Raw(bool), - - ///Returns a vector with a length no less than `min` and no more than `max` - /// - ///# Panics - /// - ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. - clamp_length(self:Raw(f32),Raw(f32)) -> self, - - ///Returns a vector with a length no more than `max` - clamp_length_max(self:Raw(f32)) -> self, - - ///Returns a vector with a length no less than `min` - clamp_length_min(self:Raw(f32)) -> self, - - ///Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding - ///error, yielding a more accurate result than an unfused multiply-add. - /// - ///Using `mul_add` *may* be more performant than an unfused multiply-add if the target - ///architecture has a dedicated fma CPU instruction. However, this is not always true, - ///and will be heavily dependant on designing algorithms with specific target hardware in - ///mind. - mul_add(self:self,self) -> self, - - ///Returns the angle (in radians) between two vectors. - /// - ///The inputs do not need to be unit vectors however they must be non-zero. - angle_between(self:self) -> Raw(f32), - - ///Returns some vector that is orthogonal to the given one. - /// - ///The input vector must be finite and non-zero. - /// - ///The output vector is not necessarily unit length. For that use - ///[`Self::any_orthonormal_vector()`] instead. - any_orthogonal_vector(&self:) -> self, - - ///Returns any unit vector that is orthogonal to the given one. - /// - ///The input vector must be unit length. - /// - ///# Panics - /// - ///Will panic if `self` is not normalized when `glam_assert` is enabled. - any_orthonormal_vector(&self:) -> self, - - ///Casts all elements of `self` to `f64`. - as_dvec3(&self:) -> Wrapped(DVec3), - - ///Casts all elements of `self` to `i32`. - as_ivec3(&self:) -> Wrapped(IVec3), - - ///Casts all elements of `self` to `u32`. - as_uvec3(&self:) -> Wrapped(UVec3), - - ) - + Fields - ( - ) - + BinOps - ( - self Add Wrapped(Vec3A) -> Wrapped(Vec3A), - self Add Raw(f32) -> Wrapped(Vec3A), - self Add self -> Wrapped(Vec3A), - self Sub Wrapped(Vec3A) -> Wrapped(Vec3A), - self Sub self -> Wrapped(Vec3A), - self Sub Raw(f32) -> Wrapped(Vec3A), - self Div Raw(f32) -> Wrapped(Vec3A), - self Div self -> Wrapped(Vec3A), - self Div Wrapped(Vec3A) -> Wrapped(Vec3A), - self Mul self -> Wrapped(Vec3A), - self Mul Wrapped(Vec3A) -> Wrapped(Vec3A), - self Mul Raw(f32) -> Wrapped(Vec3A), - self Rem Wrapped(Vec3A) -> Wrapped(Vec3A), - self Rem Raw(f32) -> Wrapped(Vec3A), - self Rem self -> Wrapped(Vec3A), - ) - + UnaryOps - ( - Neg self -> self - ) - lua impl - { - (MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}; - mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,f32)| {s.val_mut(|s| Ok(s[*idx] = val))?}; - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 4-dimensional vector. - /// - ///SIMD vector types are used for storage on supported platforms. - /// - ///This type is 16 byte aligned. - glam::f32::Vec4 : - Clone + - Debug + - Methods - ( - ///Creates a new vector. - new(Raw(f32),Raw(f32),Raw(f32),Raw(f32)) -> self, - - ///Creates a vector with all elements set to `v`. - splat(Raw(f32)) -> self, - - ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use - ///for each element of `self`. - /// - ///A true element in the mask uses the corresponding element from `if_true`, and false - ///uses the element from `if_false`. - select(Wrapped(BVec4A),self,self) -> self, - - ///Creates a 2D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. - /// - ///Truncation to [`Vec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. - /// - ///To truncate to [`Vec3A`] use [`Vec3A::from()`]. - truncate(self:) -> Wrapped(Vec3), - - ///Computes the dot product of `self` and `rhs`. - dot(self:self) -> Raw(f32), - - ///Returns a vector where every component is the dot product of `self` and `rhs`. - dot_into_vec(self:self) -> self, - - ///Returns a vector containing the minimum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. - min(self:self) -> self, - - ///Returns a vector containing the maximum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. - max(self:self) -> self, - - ///Component-wise clamping of values, similar to [`f32::clamp`]. - /// - ///Each element in `min` must be less-or-equal to the corresponding element in `max`. - /// - ///# Panics - /// - ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. - clamp(self:self,self) -> self, - - ///Returns the horizontal minimum of `self`. - /// - ///In other words this computes `min(x, y, ..)`. - min_element(self:) -> Raw(f32), - - ///Returns the horizontal maximum of `self`. - /// - ///In other words this computes `max(x, y, ..)`. - max_element(self:) -> Raw(f32), - - ///Returns a vector mask containing the result of a `==` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all - ///elements. - cmpeq(self:self) -> Wrapped(BVec4A), - - ///Returns a vector mask containing the result of a `!=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all - ///elements. - cmpne(self:self) -> Wrapped(BVec4A), - - ///Returns a vector mask containing the result of a `>=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all - ///elements. - cmpge(self:self) -> Wrapped(BVec4A), - - ///Returns a vector mask containing the result of a `>` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all - ///elements. - cmpgt(self:self) -> Wrapped(BVec4A), - - ///Returns a vector mask containing the result of a `<=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all - ///elements. - cmple(self:self) -> Wrapped(BVec4A), - - ///Returns a vector mask containing the result of a `<` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all - ///elements. - cmplt(self:self) -> Wrapped(BVec4A), - - ///Returns a vector containing the absolute value of each element of `self`. - abs(self:) -> self, - - ///Returns a vector with elements representing the sign of `self`. - /// - ///- `1.0` if the number is positive, `+0.0` or `INFINITY` - ///- `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` - ///- `NAN` if the number is `NAN` - signum(self:) -> self, - - ///Returns a vector with signs of `rhs` and the magnitudes of `self`. - copysign(self:self) -> self, - - ///Returns a bitmask with the lowest 4 bits set to the sign bits from the elements of `self`. - /// - ///A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes - ///into the first lowest bit, element `y` into the second, etc. - is_negative_bitmask(self:) -> Raw(u32), - - ///Returns `true` if, and only if, all elements are finite. If any element is either - ///`NaN`, positive or negative infinity, this will return `false`. - is_finite(self:) -> Raw(bool), - - ///Returns `true` if any elements are `NaN`. - is_nan(self:) -> Raw(bool), - - ///Performs `is_nan` on each element of self, returning a vector mask of the results. - /// - ///In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. - is_nan_mask(self:) -> Wrapped(BVec4A), - - ///Computes the length of `self`. - length(self:) -> Raw(f32), - - ///Computes the squared length of `self`. - /// - ///This is faster than `length()` as it avoids a square root operation. - length_squared(self:) -> Raw(f32), - - ///Computes `1.0 / length()`. - /// - ///For valid results, `self` must _not_ be of length zero. - length_recip(self:) -> Raw(f32), - - ///Computes the Euclidean distance between two points in space. - distance(self:self) -> Raw(f32), - - ///Compute the squared euclidean distance between two points in space. - distance_squared(self:self) -> Raw(f32), - - ///Returns `self` normalized to length 1.0. - /// - ///For valid results, `self` must _not_ be of length zero, nor very close to zero. - /// - ///See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. - /// - ///Panics - /// - ///Will panic if `self` is zero length when `glam_assert` is enabled. - normalize(self:) -> self, - - ///Returns `self` normalized to length 1.0 if possible, else returns zero. - /// - ///In particular, if the input is zero (or very close to zero), or non-finite, - ///the result of this operation will be zero. - /// - ///See also [`Self::try_normalize()`]. - normalize_or_zero(self:) -> self, - - ///Returns whether `self` is length `1.0` or not. - /// - ///Uses a precision threshold of `1e-6`. - is_normalized(self:) -> Raw(bool), - - ///Returns the vector projection of `self` onto `rhs`. - /// - ///`rhs` must be of non-zero length. - /// - ///# Panics - /// - ///Will panic if `rhs` is zero length when `glam_assert` is enabled. - project_onto(self:self) -> self, - - ///Returns the vector rejection of `self` from `rhs`. - /// - ///The vector rejection is the vector perpendicular to the projection of `self` onto - ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. - /// - ///`rhs` must be of non-zero length. - /// - ///# Panics - /// - ///Will panic if `rhs` has a length of zero when `glam_assert` is enabled. - reject_from(self:self) -> self, - - ///Returns the vector projection of `self` onto `rhs`. - /// - ///`rhs` must be normalized. - /// - ///# Panics - /// - ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. - project_onto_normalized(self:self) -> self, - - ///Returns the vector rejection of `self` from `rhs`. - /// - ///The vector rejection is the vector perpendicular to the projection of `self` onto - ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. - /// - ///`rhs` must be normalized. - /// - ///# Panics - /// - ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. - reject_from_normalized(self:self) -> self, - - ///Returns a vector containing the nearest integer to a number for each element of `self`. - ///Round half-way cases away from 0.0. - round(self:) -> self, - - ///Returns a vector containing the largest integer less than or equal to a number for each - ///element of `self`. - floor(self:) -> self, - - ///Returns a vector containing the smallest integer greater than or equal to a number for - ///each element of `self`. - ceil(self:) -> self, - - ///Returns a vector containing the integer part each element of `self`. This means numbers are - ///always truncated towards zero. - trunc(self:) -> self, - - ///Returns a vector containing the fractional part of the vector, e.g. `self - - ///self.floor()`. - /// - ///Note that this is fast but not precise for large numbers. - fract(self:) -> self, - - ///Returns a vector containing `e^self` (the exponential function) for each element of - ///`self`. - exp(self:) -> self, - - ///Returns a vector containing each element of `self` raised to the power of `n`. - powf(self:Raw(f32)) -> self, - - ///Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - recip(self:) -> self, - - ///Performs a linear interpolation between `self` and `rhs` based on the value `s`. - /// - ///When `s` is `0.0`, the result will be equal to `self`. When `s` is `1.0`, the result - ///will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly - ///extrapolated. - lerp(self:self,Raw(f32)) -> self, - - ///Returns true if the absolute difference of all elements between `self` and `rhs` is - ///less than or equal to `max_abs_diff`. - /// - ///This can be used to compare if two vectors contain similar elements. It works best when - ///comparing with a known value. The `max_abs_diff` that should be used used depends on - ///the values being compared against. - /// - ///For more see - ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - abs_diff_eq(self:self,Raw(f32)) -> Raw(bool), - - ///Returns a vector with a length no less than `min` and no more than `max` - /// - ///# Panics - /// - ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. - clamp_length(self:Raw(f32),Raw(f32)) -> self, - - ///Returns a vector with a length no more than `max` - clamp_length_max(self:Raw(f32)) -> self, - - ///Returns a vector with a length no less than `min` - clamp_length_min(self:Raw(f32)) -> self, - - ///Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding - ///error, yielding a more accurate result than an unfused multiply-add. - /// - ///Using `mul_add` *may* be more performant than an unfused multiply-add if the target - ///architecture has a dedicated fma CPU instruction. However, this is not always true, - ///and will be heavily dependant on designing algorithms with specific target hardware in - ///mind. - mul_add(self:self,self) -> self, - - ///Casts all elements of `self` to `f64`. - as_dvec4(&self:) -> Wrapped(DVec4), - - ///Casts all elements of `self` to `i32`. - as_ivec4(&self:) -> Wrapped(IVec4), - - ///Casts all elements of `self` to `u32`. - as_uvec4(&self:) -> Wrapped(UVec4), - - ) - + Fields - ( - ) - + BinOps - ( - self Add Raw(f32) -> Wrapped(Vec4), - self Add Wrapped(Vec4) -> Wrapped(Vec4), - self Add self -> Wrapped(Vec4), - self Sub Raw(f32) -> Wrapped(Vec4), - self Sub self -> Wrapped(Vec4), - self Sub Wrapped(Vec4) -> Wrapped(Vec4), - self Div Raw(f32) -> Wrapped(Vec4), - self Div self -> Wrapped(Vec4), - self Div Wrapped(Vec4) -> Wrapped(Vec4), - self Mul Raw(f32) -> Wrapped(Vec4), - self Mul self -> Wrapped(Vec4), - self Mul Wrapped(Vec4) -> Wrapped(Vec4), - self Rem self -> Wrapped(Vec4), - self Rem Wrapped(Vec4) -> Wrapped(Vec4), - self Rem Raw(f32) -> Wrapped(Vec4), - ) - + UnaryOps - ( - Neg self -> self - ) - lua impl - { - (MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}; - mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,f32)| {s.val_mut(|s| Ok(s[*idx] = val))?}; - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 2-dimensional `bool` vector mask. - glam::bool::BVec2 : - Clone + - Debug + - Methods - ( - ///Creates a new vector mask. - new(Raw(bool),Raw(bool)) -> self, - - ///Creates a vector with all elements set to `v`. - splat(Raw(bool)) -> self, - - ///Returns a bitmask with the lowest 2 bits set from the elements of `self`. - /// - ///A true element results in a `1` bit and a false element in a `0` bit. Element `x` goes - ///into the first lowest bit, element `y` into the second, etc. - bitmask(self:) -> Raw(u32), - - ///Returns true if any of the elements are true, false otherwise. - any(self:) -> Raw(bool), - - ///Returns true if all the elements are true, false otherwise. - all(self:) -> Raw(bool), - - ///Tests the value at `index`. - /// - ///Panics if `index` is greater than 1. - test(&self:Raw(usize)) -> Raw(bool), - - ///Sets the element at `index`. - /// - ///Panics if `index` is greater than 1. - set(&mut self:Raw(usize),Raw(bool)), - - ) - + Fields - ( - x: Raw(bool), - y: Raw(bool), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 3-dimensional `bool` vector mask. - glam::bool::BVec3 : - Clone + - Debug + - Methods - ( - ///Creates a new vector mask. - new(Raw(bool),Raw(bool),Raw(bool)) -> self, - - ///Creates a vector with all elements set to `v`. - splat(Raw(bool)) -> self, - - ///Returns a bitmask with the lowest 3 bits set from the elements of `self`. - /// - ///A true element results in a `1` bit and a false element in a `0` bit. Element `x` goes - ///into the first lowest bit, element `y` into the second, etc. - bitmask(self:) -> Raw(u32), - - ///Returns true if any of the elements are true, false otherwise. - any(self:) -> Raw(bool), - - ///Returns true if all the elements are true, false otherwise. - all(self:) -> Raw(bool), - - ///Tests the value at `index`. - /// - ///Panics if `index` is greater than 2. - test(&self:Raw(usize)) -> Raw(bool), - - ///Sets the element at `index`. - /// - ///Panics if `index` is greater than 2. - set(&mut self:Raw(usize),Raw(bool)), - - ) - + Fields - ( - x: Raw(bool), - y: Raw(bool), - z: Raw(bool), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 4-dimensional `bool` vector mask. - glam::bool::BVec4 : - Clone + - Debug + - Methods - ( - ///Creates a new vector mask. - new(Raw(bool),Raw(bool),Raw(bool),Raw(bool)) -> self, - - ///Creates a vector with all elements set to `v`. - splat(Raw(bool)) -> self, - - ///Returns a bitmask with the lowest 4 bits set from the elements of `self`. - /// - ///A true element results in a `1` bit and a false element in a `0` bit. Element `x` goes - ///into the first lowest bit, element `y` into the second, etc. - bitmask(self:) -> Raw(u32), - - ///Returns true if any of the elements are true, false otherwise. - any(self:) -> Raw(bool), - - ///Returns true if all the elements are true, false otherwise. - all(self:) -> Raw(bool), - - ///Tests the value at `index`. - /// - ///Panics if `index` is greater than 3. - test(&self:Raw(usize)) -> Raw(bool), - - ///Sets the element at `index`. - /// - ///Panics if `index` is greater than 3. - set(&mut self:Raw(usize),Raw(bool)), - - ) - + Fields - ( - x: Raw(bool), - y: Raw(bool), - z: Raw(bool), - w: Raw(bool), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 3-dimensional SIMD vector mask. - /// - ///This type is 16 byte aligned. - glam::bool::BVec3A : - Clone + - Debug + - Methods - ( - ///Creates a new vector mask. - new(Raw(bool),Raw(bool),Raw(bool)) -> self, - - ///Creates a vector with all elements set to `v`. - splat(Raw(bool)) -> self, - - ///Returns a bitmask with the lowest 3 bits set from the elements of `self`. - /// - ///A true element results in a `1` bit and a false element in a `0` bit. Element `x` goes - ///into the first lowest bit, element `y` into the second, etc. - bitmask(self:) -> Raw(u32), - - ///Returns true if any of the elements are true, false otherwise. - any(self:) -> Raw(bool), - - ///Returns true if all the elements are true, false otherwise. - all(self:) -> Raw(bool), - - ///Tests the value at `index`. - /// - ///Panics if `index` is greater than 2. - test(&self:Raw(usize)) -> Raw(bool), - - ///Sets the element at `index`. - /// - ///Panics if `index` is greater than 2. - set(&mut self:Raw(usize),Raw(bool)), - - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 4-dimensional SIMD vector mask. - /// - ///This type is 16 byte aligned. - glam::bool::BVec4A : - Clone + - Debug + - Methods - ( - ///Creates a new vector mask. - new(Raw(bool),Raw(bool),Raw(bool),Raw(bool)) -> self, - - ///Creates a vector with all elements set to `v`. - splat(Raw(bool)) -> self, - - ///Returns a bitmask with the lowest 4 bits set from the elements of `self`. - /// - ///A true element results in a `1` bit and a false element in a `0` bit. Element `x` goes - ///into the first lowest bit, element `y` into the second, etc. - bitmask(self:) -> Raw(u32), - - ///Returns true if any of the elements are true, false otherwise. - any(self:) -> Raw(bool), - - ///Returns true if all the elements are true, false otherwise. - all(self:) -> Raw(bool), - - ///Tests the value at `index`. - /// - ///Panics if `index` is greater than 3. - test(&self:Raw(usize)) -> Raw(bool), - - ///Sets the element at `index`. - /// - ///Panics if `index` is greater than 3. - set(&mut self:Raw(usize),Raw(bool)), - - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 2-dimensional vector. - glam::f64::DVec2 : - Clone + - Debug + - Methods - ( - ///Creates a new vector. - new(Raw(f64),Raw(f64)) -> self, - - ///Creates a vector with all elements set to `v`. - splat(Raw(f64)) -> self, - - ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use - ///for each element of `self`. - /// - ///A true element in the mask uses the corresponding element from `if_true`, and false - ///uses the element from `if_false`. - select(Wrapped(BVec2),self,self) -> self, - - ///Creates a 3D vector from `self` and the given `z` value. - extend(self:Raw(f64)) -> Wrapped(DVec3), - - ///Computes the dot product of `self` and `rhs`. - dot(self:self) -> Raw(f64), - - ///Returns a vector where every component is the dot product of `self` and `rhs`. - dot_into_vec(self:self) -> self, - - ///Returns a vector containing the minimum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. - min(self:self) -> self, - - ///Returns a vector containing the maximum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. - max(self:self) -> self, - - ///Component-wise clamping of values, similar to [`f64::clamp`]. - /// - ///Each element in `min` must be less-or-equal to the corresponding element in `max`. - /// - ///# Panics - /// - ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. - clamp(self:self,self) -> self, - - ///Returns the horizontal minimum of `self`. - /// - ///In other words this computes `min(x, y, ..)`. - min_element(self:) -> Raw(f64), - - ///Returns the horizontal maximum of `self`. - /// - ///In other words this computes `max(x, y, ..)`. - max_element(self:) -> Raw(f64), - - ///Returns a vector mask containing the result of a `==` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all - ///elements. - cmpeq(self:self) -> Wrapped(BVec2), - - ///Returns a vector mask containing the result of a `!=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all - ///elements. - cmpne(self:self) -> Wrapped(BVec2), - - ///Returns a vector mask containing the result of a `>=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all - ///elements. - cmpge(self:self) -> Wrapped(BVec2), - - ///Returns a vector mask containing the result of a `>` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all - ///elements. - cmpgt(self:self) -> Wrapped(BVec2), - - ///Returns a vector mask containing the result of a `<=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all - ///elements. - cmple(self:self) -> Wrapped(BVec2), - - ///Returns a vector mask containing the result of a `<` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all - ///elements. - cmplt(self:self) -> Wrapped(BVec2), - - ///Returns a vector containing the absolute value of each element of `self`. - abs(self:) -> self, - - ///Returns a vector with elements representing the sign of `self`. - /// - ///- `1.0` if the number is positive, `+0.0` or `INFINITY` - ///- `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` - ///- `NAN` if the number is `NAN` - signum(self:) -> self, - - ///Returns a vector with signs of `rhs` and the magnitudes of `self`. - copysign(self:self) -> self, - - ///Returns a bitmask with the lowest 2 bits set to the sign bits from the elements of `self`. - /// - ///A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes - ///into the first lowest bit, element `y` into the second, etc. - is_negative_bitmask(self:) -> Raw(u32), - - ///Returns `true` if, and only if, all elements are finite. If any element is either - ///`NaN`, positive or negative infinity, this will return `false`. - is_finite(self:) -> Raw(bool), - - ///Returns `true` if any elements are `NaN`. - is_nan(self:) -> Raw(bool), - - ///Performs `is_nan` on each element of self, returning a vector mask of the results. - /// - ///In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. - is_nan_mask(self:) -> Wrapped(BVec2), - - ///Computes the length of `self`. - length(self:) -> Raw(f64), - - ///Computes the squared length of `self`. - /// - ///This is faster than `length()` as it avoids a square root operation. - length_squared(self:) -> Raw(f64), - - ///Computes `1.0 / length()`. - /// - ///For valid results, `self` must _not_ be of length zero. - length_recip(self:) -> Raw(f64), - - ///Computes the Euclidean distance between two points in space. - distance(self:self) -> Raw(f64), - - ///Compute the squared euclidean distance between two points in space. - distance_squared(self:self) -> Raw(f64), - - ///Returns `self` normalized to length 1.0. - /// - ///For valid results, `self` must _not_ be of length zero, nor very close to zero. - /// - ///See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. - /// - ///Panics - /// - ///Will panic if `self` is zero length when `glam_assert` is enabled. - normalize(self:) -> self, - - ///Returns `self` normalized to length 1.0 if possible, else returns zero. - /// - ///In particular, if the input is zero (or very close to zero), or non-finite, - ///the result of this operation will be zero. - /// - ///See also [`Self::try_normalize()`]. - normalize_or_zero(self:) -> self, - - ///Returns whether `self` is length `1.0` or not. - /// - ///Uses a precision threshold of `1e-6`. - is_normalized(self:) -> Raw(bool), - - ///Returns the vector projection of `self` onto `rhs`. - /// - ///`rhs` must be of non-zero length. - /// - ///# Panics - /// - ///Will panic if `rhs` is zero length when `glam_assert` is enabled. - project_onto(self:self) -> self, - - ///Returns the vector rejection of `self` from `rhs`. - /// - ///The vector rejection is the vector perpendicular to the projection of `self` onto - ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. - /// - ///`rhs` must be of non-zero length. - /// - ///# Panics - /// - ///Will panic if `rhs` has a length of zero when `glam_assert` is enabled. - reject_from(self:self) -> self, - - ///Returns the vector projection of `self` onto `rhs`. - /// - ///`rhs` must be normalized. - /// - ///# Panics - /// - ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. - project_onto_normalized(self:self) -> self, - - ///Returns the vector rejection of `self` from `rhs`. - /// - ///The vector rejection is the vector perpendicular to the projection of `self` onto - ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. - /// - ///`rhs` must be normalized. - /// - ///# Panics - /// - ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. - reject_from_normalized(self:self) -> self, - - ///Returns a vector containing the nearest integer to a number for each element of `self`. - ///Round half-way cases away from 0.0. - round(self:) -> self, - - ///Returns a vector containing the largest integer less than or equal to a number for each - ///element of `self`. - floor(self:) -> self, - - ///Returns a vector containing the smallest integer greater than or equal to a number for - ///each element of `self`. - ceil(self:) -> self, - - ///Returns a vector containing the integer part each element of `self`. This means numbers are - ///always truncated towards zero. - trunc(self:) -> self, - - ///Returns a vector containing the fractional part of the vector, e.g. `self - - ///self.floor()`. - /// - ///Note that this is fast but not precise for large numbers. - fract(self:) -> self, - - ///Returns a vector containing `e^self` (the exponential function) for each element of - ///`self`. - exp(self:) -> self, - - ///Returns a vector containing each element of `self` raised to the power of `n`. - powf(self:Raw(f64)) -> self, - - ///Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - recip(self:) -> self, - - ///Performs a linear interpolation between `self` and `rhs` based on the value `s`. - /// - ///When `s` is `0.0`, the result will be equal to `self`. When `s` is `1.0`, the result - ///will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly - ///extrapolated. - lerp(self:self,Raw(f64)) -> self, - - ///Returns true if the absolute difference of all elements between `self` and `rhs` is - ///less than or equal to `max_abs_diff`. - /// - ///This can be used to compare if two vectors contain similar elements. It works best when - ///comparing with a known value. The `max_abs_diff` that should be used used depends on - ///the values being compared against. - /// - ///For more see - ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - abs_diff_eq(self:self,Raw(f64)) -> Raw(bool), - - ///Returns a vector with a length no less than `min` and no more than `max` - /// - ///# Panics - /// - ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. - clamp_length(self:Raw(f64),Raw(f64)) -> self, - - ///Returns a vector with a length no more than `max` - clamp_length_max(self:Raw(f64)) -> self, - - ///Returns a vector with a length no less than `min` - clamp_length_min(self:Raw(f64)) -> self, - - ///Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding - ///error, yielding a more accurate result than an unfused multiply-add. - /// - ///Using `mul_add` *may* be more performant than an unfused multiply-add if the target - ///architecture has a dedicated fma CPU instruction. However, this is not always true, - ///and will be heavily dependant on designing algorithms with specific target hardware in - ///mind. - mul_add(self:self,self) -> self, - - ///Creates a 2D vector containing `[angle.cos(), angle.sin()]`. This can be used in - ///conjunction with the [`rotate()`][Self::rotate()] method, e.g. - ///`DVec2::from_angle(PI).rotate(DVec2::Y)` will create the vector `[-1, 0]` - ///and rotate [`DVec2::Y`] around it returning `-DVec2::Y`. - from_angle(Raw(f64)) -> self, - - ///Returns the angle (in radians) between `self` and `rhs` in the range `[-π, +π]`. - /// - ///The inputs do not need to be unit vectors however they must be non-zero. - angle_between(self:self) -> Raw(f64), - - ///Returns a vector that is equal to `self` rotated by 90 degrees. - perp(self:) -> self, - - ///The perpendicular dot product of `self` and `rhs`. - ///Also known as the wedge product, 2D cross product, and determinant. - perp_dot(self:self) -> Raw(f64), - - ///Returns `rhs` rotated by the angle of `self`. If `self` is normalized, - ///then this just rotation. This is what you usually want. Otherwise, - ///it will be like a rotation with a multiplication by `self`'s length. - rotate(self:self) -> self, - - ///Casts all elements of `self` to `f32`. - as_vec2(&self:) -> Wrapped(Vec2), - - ///Casts all elements of `self` to `i32`. - as_ivec2(&self:) -> Wrapped(IVec2), - - ///Casts all elements of `self` to `u32`. - as_uvec2(&self:) -> Wrapped(UVec2), - - ) - + Fields - ( - x: Raw(f64), - y: Raw(f64), - ) - + BinOps - ( - self Add self -> Wrapped(DVec2), - self Add Raw(f64) -> Wrapped(DVec2), - self Add Wrapped(DVec2) -> Wrapped(DVec2), - self Sub Raw(f64) -> Wrapped(DVec2), - self Sub Wrapped(DVec2) -> Wrapped(DVec2), - self Sub self -> Wrapped(DVec2), - self Div self -> Wrapped(DVec2), - self Div Wrapped(DVec2) -> Wrapped(DVec2), - self Div Raw(f64) -> Wrapped(DVec2), - self Mul Wrapped(DVec2) -> Wrapped(DVec2), - self Mul self -> Wrapped(DVec2), - self Mul Raw(f64) -> Wrapped(DVec2), - self Rem self -> Wrapped(DVec2), - self Rem Raw(f64) -> Wrapped(DVec2), - self Rem Wrapped(DVec2) -> Wrapped(DVec2), - ) - + UnaryOps - ( - Neg self -> self - ) - lua impl - { - (MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}; - mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,f64)| {s.val_mut(|s| Ok(s[*idx] = val))?}; - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 3-dimensional vector. - glam::f64::DVec3 : - Clone + - Debug + - Methods - ( - ///Creates a new vector. - new(Raw(f64),Raw(f64),Raw(f64)) -> self, - - ///Creates a vector with all elements set to `v`. - splat(Raw(f64)) -> self, - - ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use - ///for each element of `self`. - /// - ///A true element in the mask uses the corresponding element from `if_true`, and false - ///uses the element from `if_false`. - select(Wrapped(BVec3),self,self) -> self, - - ///Creates a 4D vector from `self` and the given `w` value. - extend(self:Raw(f64)) -> Wrapped(DVec4), - - ///Creates a 2D vector from the `x` and `y` elements of `self`, discarding `z`. - /// - ///Truncation may also be performed by using [`self.xy()`][crate::swizzles::Vec3Swizzles::xy()]. - truncate(self:) -> Wrapped(DVec2), - - ///Computes the dot product of `self` and `rhs`. - dot(self:self) -> Raw(f64), - - ///Returns a vector where every component is the dot product of `self` and `rhs`. - dot_into_vec(self:self) -> self, - - ///Computes the cross product of `self` and `rhs`. - cross(self:self) -> self, - - ///Returns a vector containing the minimum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. - min(self:self) -> self, - - ///Returns a vector containing the maximum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. - max(self:self) -> self, - - ///Component-wise clamping of values, similar to [`f64::clamp`]. - /// - ///Each element in `min` must be less-or-equal to the corresponding element in `max`. - /// - ///# Panics - /// - ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. - clamp(self:self,self) -> self, - - ///Returns the horizontal minimum of `self`. - /// - ///In other words this computes `min(x, y, ..)`. - min_element(self:) -> Raw(f64), - - ///Returns the horizontal maximum of `self`. - /// - ///In other words this computes `max(x, y, ..)`. - max_element(self:) -> Raw(f64), - - ///Returns a vector mask containing the result of a `==` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all - ///elements. - cmpeq(self:self) -> Wrapped(BVec3), - - ///Returns a vector mask containing the result of a `!=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all - ///elements. - cmpne(self:self) -> Wrapped(BVec3), - - ///Returns a vector mask containing the result of a `>=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all - ///elements. - cmpge(self:self) -> Wrapped(BVec3), - - ///Returns a vector mask containing the result of a `>` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all - ///elements. - cmpgt(self:self) -> Wrapped(BVec3), - - ///Returns a vector mask containing the result of a `<=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all - ///elements. - cmple(self:self) -> Wrapped(BVec3), - - ///Returns a vector mask containing the result of a `<` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all - ///elements. - cmplt(self:self) -> Wrapped(BVec3), - - ///Returns a vector containing the absolute value of each element of `self`. - abs(self:) -> self, - - ///Returns a vector with elements representing the sign of `self`. - /// - ///- `1.0` if the number is positive, `+0.0` or `INFINITY` - ///- `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` - ///- `NAN` if the number is `NAN` - signum(self:) -> self, - - ///Returns a vector with signs of `rhs` and the magnitudes of `self`. - copysign(self:self) -> self, - - ///Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of `self`. - /// - ///A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes - ///into the first lowest bit, element `y` into the second, etc. - is_negative_bitmask(self:) -> Raw(u32), - - ///Returns `true` if, and only if, all elements are finite. If any element is either - ///`NaN`, positive or negative infinity, this will return `false`. - is_finite(self:) -> Raw(bool), - - ///Returns `true` if any elements are `NaN`. - is_nan(self:) -> Raw(bool), - - ///Performs `is_nan` on each element of self, returning a vector mask of the results. - /// - ///In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. - is_nan_mask(self:) -> Wrapped(BVec3), - - ///Computes the length of `self`. - length(self:) -> Raw(f64), - - ///Computes the squared length of `self`. - /// - ///This is faster than `length()` as it avoids a square root operation. - length_squared(self:) -> Raw(f64), - - ///Computes `1.0 / length()`. - /// - ///For valid results, `self` must _not_ be of length zero. - length_recip(self:) -> Raw(f64), - - ///Computes the Euclidean distance between two points in space. - distance(self:self) -> Raw(f64), - - ///Compute the squared euclidean distance between two points in space. - distance_squared(self:self) -> Raw(f64), - - ///Returns `self` normalized to length 1.0. - /// - ///For valid results, `self` must _not_ be of length zero, nor very close to zero. - /// - ///See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. - /// - ///Panics - /// - ///Will panic if `self` is zero length when `glam_assert` is enabled. - normalize(self:) -> self, - - ///Returns `self` normalized to length 1.0 if possible, else returns zero. - /// - ///In particular, if the input is zero (or very close to zero), or non-finite, - ///the result of this operation will be zero. - /// - ///See also [`Self::try_normalize()`]. - normalize_or_zero(self:) -> self, - - ///Returns whether `self` is length `1.0` or not. - /// - ///Uses a precision threshold of `1e-6`. - is_normalized(self:) -> Raw(bool), - - ///Returns the vector projection of `self` onto `rhs`. - /// - ///`rhs` must be of non-zero length. - /// - ///# Panics - /// - ///Will panic if `rhs` is zero length when `glam_assert` is enabled. - project_onto(self:self) -> self, - - ///Returns the vector rejection of `self` from `rhs`. - /// - ///The vector rejection is the vector perpendicular to the projection of `self` onto - ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. - /// - ///`rhs` must be of non-zero length. - /// - ///# Panics - /// - ///Will panic if `rhs` has a length of zero when `glam_assert` is enabled. - reject_from(self:self) -> self, - - ///Returns the vector projection of `self` onto `rhs`. - /// - ///`rhs` must be normalized. - /// - ///# Panics - /// - ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. - project_onto_normalized(self:self) -> self, - - ///Returns the vector rejection of `self` from `rhs`. - /// - ///The vector rejection is the vector perpendicular to the projection of `self` onto - ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. - /// - ///`rhs` must be normalized. - /// - ///# Panics - /// - ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. - reject_from_normalized(self:self) -> self, - - ///Returns a vector containing the nearest integer to a number for each element of `self`. - ///Round half-way cases away from 0.0. - round(self:) -> self, - - ///Returns a vector containing the largest integer less than or equal to a number for each - ///element of `self`. - floor(self:) -> self, - - ///Returns a vector containing the smallest integer greater than or equal to a number for - ///each element of `self`. - ceil(self:) -> self, - - ///Returns a vector containing the integer part each element of `self`. This means numbers are - ///always truncated towards zero. - trunc(self:) -> self, - - ///Returns a vector containing the fractional part of the vector, e.g. `self - - ///self.floor()`. - /// - ///Note that this is fast but not precise for large numbers. - fract(self:) -> self, - - ///Returns a vector containing `e^self` (the exponential function) for each element of - ///`self`. - exp(self:) -> self, - - ///Returns a vector containing each element of `self` raised to the power of `n`. - powf(self:Raw(f64)) -> self, - - ///Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - recip(self:) -> self, - - ///Performs a linear interpolation between `self` and `rhs` based on the value `s`. - /// - ///When `s` is `0.0`, the result will be equal to `self`. When `s` is `1.0`, the result - ///will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly - ///extrapolated. - lerp(self:self,Raw(f64)) -> self, - - ///Returns true if the absolute difference of all elements between `self` and `rhs` is - ///less than or equal to `max_abs_diff`. - /// - ///This can be used to compare if two vectors contain similar elements. It works best when - ///comparing with a known value. The `max_abs_diff` that should be used used depends on - ///the values being compared against. - /// - ///For more see - ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - abs_diff_eq(self:self,Raw(f64)) -> Raw(bool), - - ///Returns a vector with a length no less than `min` and no more than `max` - /// - ///# Panics - /// - ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. - clamp_length(self:Raw(f64),Raw(f64)) -> self, - - ///Returns a vector with a length no more than `max` - clamp_length_max(self:Raw(f64)) -> self, - - ///Returns a vector with a length no less than `min` - clamp_length_min(self:Raw(f64)) -> self, - - ///Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding - ///error, yielding a more accurate result than an unfused multiply-add. - /// - ///Using `mul_add` *may* be more performant than an unfused multiply-add if the target - ///architecture has a dedicated fma CPU instruction. However, this is not always true, - ///and will be heavily dependant on designing algorithms with specific target hardware in - ///mind. - mul_add(self:self,self) -> self, - - ///Returns the angle (in radians) between two vectors. - /// - ///The inputs do not need to be unit vectors however they must be non-zero. - angle_between(self:self) -> Raw(f64), - - ///Returns some vector that is orthogonal to the given one. - /// - ///The input vector must be finite and non-zero. - /// - ///The output vector is not necessarily unit length. For that use - ///[`Self::any_orthonormal_vector()`] instead. - any_orthogonal_vector(&self:) -> self, - - ///Returns any unit vector that is orthogonal to the given one. - /// - ///The input vector must be unit length. - /// - ///# Panics - /// - ///Will panic if `self` is not normalized when `glam_assert` is enabled. - any_orthonormal_vector(&self:) -> self, - - ///Casts all elements of `self` to `f32`. - as_vec3(&self:) -> Wrapped(Vec3), - - ///Casts all elements of `self` to `f32`. - as_vec3a(&self:) -> Wrapped(Vec3A), - - ///Casts all elements of `self` to `i32`. - as_ivec3(&self:) -> Wrapped(IVec3), - - ///Casts all elements of `self` to `u32`. - as_uvec3(&self:) -> Wrapped(UVec3), - - ) - + Fields - ( - x: Raw(f64), - y: Raw(f64), - z: Raw(f64), - ) - + BinOps - ( - self Add Raw(f64) -> Wrapped(DVec3), - self Add Wrapped(DVec3) -> Wrapped(DVec3), - self Add self -> Wrapped(DVec3), - self Sub Wrapped(DVec3) -> Wrapped(DVec3), - self Sub self -> Wrapped(DVec3), - self Sub Raw(f64) -> Wrapped(DVec3), - self Div Raw(f64) -> Wrapped(DVec3), - self Div Wrapped(DVec3) -> Wrapped(DVec3), - self Div self -> Wrapped(DVec3), - self Mul Raw(f64) -> Wrapped(DVec3), - self Mul self -> Wrapped(DVec3), - self Mul Wrapped(DVec3) -> Wrapped(DVec3), - self Rem Raw(f64) -> Wrapped(DVec3), - self Rem self -> Wrapped(DVec3), - self Rem Wrapped(DVec3) -> Wrapped(DVec3), - ) - + UnaryOps - ( - Neg self -> self - ) - lua impl - { - (MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}; - mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,f64)| {s.val_mut(|s| Ok(s[*idx] = val))?}; - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 4-dimensional vector. - glam::f64::DVec4 : - Clone + - Debug + - Methods - ( - ///Creates a new vector. - new(Raw(f64),Raw(f64),Raw(f64),Raw(f64)) -> self, - - ///Creates a vector with all elements set to `v`. - splat(Raw(f64)) -> self, - - ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use - ///for each element of `self`. - /// - ///A true element in the mask uses the corresponding element from `if_true`, and false - ///uses the element from `if_false`. - select(Wrapped(BVec4),self,self) -> self, - - ///Creates a 2D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. - /// - ///Truncation to [`DVec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. - truncate(self:) -> Wrapped(DVec3), - - ///Computes the dot product of `self` and `rhs`. - dot(self:self) -> Raw(f64), - - ///Returns a vector where every component is the dot product of `self` and `rhs`. - dot_into_vec(self:self) -> self, - - ///Returns a vector containing the minimum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. - min(self:self) -> self, - - ///Returns a vector containing the maximum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. - max(self:self) -> self, - - ///Component-wise clamping of values, similar to [`f64::clamp`]. - /// - ///Each element in `min` must be less-or-equal to the corresponding element in `max`. - /// - ///# Panics - /// - ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. - clamp(self:self,self) -> self, - - ///Returns the horizontal minimum of `self`. - /// - ///In other words this computes `min(x, y, ..)`. - min_element(self:) -> Raw(f64), - - ///Returns the horizontal maximum of `self`. - /// - ///In other words this computes `max(x, y, ..)`. - max_element(self:) -> Raw(f64), - - ///Returns a vector mask containing the result of a `==` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all - ///elements. - cmpeq(self:self) -> Wrapped(BVec4), - - ///Returns a vector mask containing the result of a `!=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all - ///elements. - cmpne(self:self) -> Wrapped(BVec4), - - ///Returns a vector mask containing the result of a `>=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all - ///elements. - cmpge(self:self) -> Wrapped(BVec4), - - ///Returns a vector mask containing the result of a `>` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all - ///elements. - cmpgt(self:self) -> Wrapped(BVec4), - - ///Returns a vector mask containing the result of a `<=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all - ///elements. - cmple(self:self) -> Wrapped(BVec4), - - ///Returns a vector mask containing the result of a `<` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all - ///elements. - cmplt(self:self) -> Wrapped(BVec4), - - ///Returns a vector containing the absolute value of each element of `self`. - abs(self:) -> self, - - ///Returns a vector with elements representing the sign of `self`. - /// - ///- `1.0` if the number is positive, `+0.0` or `INFINITY` - ///- `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` - ///- `NAN` if the number is `NAN` - signum(self:) -> self, - - ///Returns a vector with signs of `rhs` and the magnitudes of `self`. - copysign(self:self) -> self, - - ///Returns a bitmask with the lowest 4 bits set to the sign bits from the elements of `self`. - /// - ///A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes - ///into the first lowest bit, element `y` into the second, etc. - is_negative_bitmask(self:) -> Raw(u32), - - ///Returns `true` if, and only if, all elements are finite. If any element is either - ///`NaN`, positive or negative infinity, this will return `false`. - is_finite(self:) -> Raw(bool), - - ///Returns `true` if any elements are `NaN`. - is_nan(self:) -> Raw(bool), - - ///Performs `is_nan` on each element of self, returning a vector mask of the results. - /// - ///In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. - is_nan_mask(self:) -> Wrapped(BVec4), - - ///Computes the length of `self`. - length(self:) -> Raw(f64), - - ///Computes the squared length of `self`. - /// - ///This is faster than `length()` as it avoids a square root operation. - length_squared(self:) -> Raw(f64), - - ///Computes `1.0 / length()`. - /// - ///For valid results, `self` must _not_ be of length zero. - length_recip(self:) -> Raw(f64), - - ///Computes the Euclidean distance between two points in space. - distance(self:self) -> Raw(f64), - - ///Compute the squared euclidean distance between two points in space. - distance_squared(self:self) -> Raw(f64), - - ///Returns `self` normalized to length 1.0. - /// - ///For valid results, `self` must _not_ be of length zero, nor very close to zero. - /// - ///See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. - /// - ///Panics - /// - ///Will panic if `self` is zero length when `glam_assert` is enabled. - normalize(self:) -> self, - - ///Returns `self` normalized to length 1.0 if possible, else returns zero. - /// - ///In particular, if the input is zero (or very close to zero), or non-finite, - ///the result of this operation will be zero. - /// - ///See also [`Self::try_normalize()`]. - normalize_or_zero(self:) -> self, - - ///Returns whether `self` is length `1.0` or not. - /// - ///Uses a precision threshold of `1e-6`. - is_normalized(self:) -> Raw(bool), - - ///Returns the vector projection of `self` onto `rhs`. - /// - ///`rhs` must be of non-zero length. - /// - ///# Panics - /// - ///Will panic if `rhs` is zero length when `glam_assert` is enabled. - project_onto(self:self) -> self, - - ///Returns the vector rejection of `self` from `rhs`. - /// - ///The vector rejection is the vector perpendicular to the projection of `self` onto - ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. - /// - ///`rhs` must be of non-zero length. - /// - ///# Panics - /// - ///Will panic if `rhs` has a length of zero when `glam_assert` is enabled. - reject_from(self:self) -> self, - - ///Returns the vector projection of `self` onto `rhs`. - /// - ///`rhs` must be normalized. - /// - ///# Panics - /// - ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. - project_onto_normalized(self:self) -> self, - - ///Returns the vector rejection of `self` from `rhs`. - /// - ///The vector rejection is the vector perpendicular to the projection of `self` onto - ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. - /// - ///`rhs` must be normalized. - /// - ///# Panics - /// - ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. - reject_from_normalized(self:self) -> self, - - ///Returns a vector containing the nearest integer to a number for each element of `self`. - ///Round half-way cases away from 0.0. - round(self:) -> self, - - ///Returns a vector containing the largest integer less than or equal to a number for each - ///element of `self`. - floor(self:) -> self, - - ///Returns a vector containing the smallest integer greater than or equal to a number for - ///each element of `self`. - ceil(self:) -> self, - - ///Returns a vector containing the integer part each element of `self`. This means numbers are - ///always truncated towards zero. - trunc(self:) -> self, - - ///Returns a vector containing the fractional part of the vector, e.g. `self - - ///self.floor()`. - /// - ///Note that this is fast but not precise for large numbers. - fract(self:) -> self, - - ///Returns a vector containing `e^self` (the exponential function) for each element of - ///`self`. - exp(self:) -> self, - - ///Returns a vector containing each element of `self` raised to the power of `n`. - powf(self:Raw(f64)) -> self, - - ///Returns a vector containing the reciprocal `1.0/n` of each element of `self`. - recip(self:) -> self, - - ///Performs a linear interpolation between `self` and `rhs` based on the value `s`. - /// - ///When `s` is `0.0`, the result will be equal to `self`. When `s` is `1.0`, the result - ///will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly - ///extrapolated. - lerp(self:self,Raw(f64)) -> self, - - ///Returns true if the absolute difference of all elements between `self` and `rhs` is - ///less than or equal to `max_abs_diff`. - /// - ///This can be used to compare if two vectors contain similar elements. It works best when - ///comparing with a known value. The `max_abs_diff` that should be used used depends on - ///the values being compared against. - /// - ///For more see - ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - abs_diff_eq(self:self,Raw(f64)) -> Raw(bool), - - ///Returns a vector with a length no less than `min` and no more than `max` - /// - ///# Panics - /// - ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. - clamp_length(self:Raw(f64),Raw(f64)) -> self, - - ///Returns a vector with a length no more than `max` - clamp_length_max(self:Raw(f64)) -> self, - - ///Returns a vector with a length no less than `min` - clamp_length_min(self:Raw(f64)) -> self, - - ///Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding - ///error, yielding a more accurate result than an unfused multiply-add. - /// - ///Using `mul_add` *may* be more performant than an unfused multiply-add if the target - ///architecture has a dedicated fma CPU instruction. However, this is not always true, - ///and will be heavily dependant on designing algorithms with specific target hardware in - ///mind. - mul_add(self:self,self) -> self, - - ///Casts all elements of `self` to `f32`. - as_vec4(&self:) -> Wrapped(Vec4), - - ///Casts all elements of `self` to `i32`. - as_ivec4(&self:) -> Wrapped(IVec4), - - ///Casts all elements of `self` to `u32`. - as_uvec4(&self:) -> Wrapped(UVec4), - - ) - + Fields - ( - x: Raw(f64), - y: Raw(f64), - z: Raw(f64), - w: Raw(f64), - ) - + BinOps - ( - self Add Raw(f64) -> Wrapped(DVec4), - self Add self -> Wrapped(DVec4), - self Add Wrapped(DVec4) -> Wrapped(DVec4), - self Sub Raw(f64) -> Wrapped(DVec4), - self Sub Wrapped(DVec4) -> Wrapped(DVec4), - self Sub self -> Wrapped(DVec4), - self Div Wrapped(DVec4) -> Wrapped(DVec4), - self Div self -> Wrapped(DVec4), - self Div Raw(f64) -> Wrapped(DVec4), - self Mul Wrapped(DVec4) -> Wrapped(DVec4), - self Mul Raw(f64) -> Wrapped(DVec4), - self Mul self -> Wrapped(DVec4), - self Rem Raw(f64) -> Wrapped(DVec4), - self Rem self -> Wrapped(DVec4), - self Rem Wrapped(DVec4) -> Wrapped(DVec4), - ) - + UnaryOps - ( - Neg self -> self - ) - lua impl - { - (MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}; - mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,f64)| {s.val_mut(|s| Ok(s[*idx] = val))?}; - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 2-dimensional vector. - glam::i32::IVec2 : - Clone + - Debug + - Methods - ( - ///Creates a new vector. - new(Raw(i32),Raw(i32)) -> self, - - ///Creates a vector with all elements set to `v`. - splat(Raw(i32)) -> self, - - ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use - ///for each element of `self`. - /// - ///A true element in the mask uses the corresponding element from `if_true`, and false - ///uses the element from `if_false`. - select(Wrapped(BVec2),self,self) -> self, - - ///Creates a 3D vector from `self` and the given `z` value. - extend(self:Raw(i32)) -> Wrapped(IVec3), - - ///Computes the dot product of `self` and `rhs`. - dot(self:self) -> Raw(i32), - - ///Returns a vector where every component is the dot product of `self` and `rhs`. - dot_into_vec(self:self) -> self, - - ///Returns a vector containing the minimum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. - min(self:self) -> self, - - ///Returns a vector containing the maximum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. - max(self:self) -> self, - - ///Component-wise clamping of values, similar to [`i32::clamp`]. - /// - ///Each element in `min` must be less-or-equal to the corresponding element in `max`. - /// - ///# Panics - /// - ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. - clamp(self:self,self) -> self, - - ///Returns the horizontal minimum of `self`. - /// - ///In other words this computes `min(x, y, ..)`. - min_element(self:) -> Raw(i32), - - ///Returns the horizontal maximum of `self`. - /// - ///In other words this computes `max(x, y, ..)`. - max_element(self:) -> Raw(i32), - - ///Returns a vector mask containing the result of a `==` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all - ///elements. - cmpeq(self:self) -> Wrapped(BVec2), - - ///Returns a vector mask containing the result of a `!=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all - ///elements. - cmpne(self:self) -> Wrapped(BVec2), - - ///Returns a vector mask containing the result of a `>=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all - ///elements. - cmpge(self:self) -> Wrapped(BVec2), - - ///Returns a vector mask containing the result of a `>` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all - ///elements. - cmpgt(self:self) -> Wrapped(BVec2), - - ///Returns a vector mask containing the result of a `<=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all - ///elements. - cmple(self:self) -> Wrapped(BVec2), - - ///Returns a vector mask containing the result of a `<` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all - ///elements. - cmplt(self:self) -> Wrapped(BVec2), - - ///Returns a vector containing the absolute value of each element of `self`. - abs(self:) -> self, - - ///Returns a vector with elements representing the sign of `self`. - /// - /// - `0` if the number is zero - /// - `1` if the number is positive - /// - `-1` if the number is negative - signum(self:) -> self, - - ///Returns a bitmask with the lowest 2 bits set to the sign bits from the elements of `self`. - /// - ///A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes - ///into the first lowest bit, element `y` into the second, etc. - is_negative_bitmask(self:) -> Raw(u32), - - ///Computes the squared length of `self`. - length_squared(self:) -> Raw(i32), - - ///Compute the squared euclidean distance between two points in space. - distance_squared(self:self) -> Raw(i32), - - ///Returns a vector that is equal to `self` rotated by 90 degrees. - perp(self:) -> self, - - ///The perpendicular dot product of `self` and `rhs`. - ///Also known as the wedge product, 2D cross product, and determinant. - perp_dot(self:self) -> Raw(i32), - - ///Returns `rhs` rotated by the angle of `self`. If `self` is normalized, - ///then this just rotation. This is what you usually want. Otherwise, - ///it will be like a rotation with a multiplication by `self`'s length. - rotate(self:self) -> self, - - ///Casts all elements of `self` to `f32`. - as_vec2(&self:) -> Wrapped(Vec2), - - ///Casts all elements of `self` to `f64`. - as_dvec2(&self:) -> Wrapped(DVec2), - - ///Casts all elements of `self` to `u32`. - as_uvec2(&self:) -> Wrapped(UVec2), - - ) - + Fields - ( - x: Raw(i32), - y: Raw(i32), - ) - + BinOps - ( - self Add self -> Wrapped(IVec2), - self Add Wrapped(IVec2) -> Wrapped(IVec2), - self Add Raw(i32) -> Wrapped(IVec2), - self Sub Wrapped(IVec2) -> Wrapped(IVec2), - self Sub Raw(i32) -> Wrapped(IVec2), - self Sub self -> Wrapped(IVec2), - self Div Raw(i32) -> Wrapped(IVec2), - self Div Wrapped(IVec2) -> Wrapped(IVec2), - self Div self -> Wrapped(IVec2), - self Mul self -> Wrapped(IVec2), - self Mul Wrapped(IVec2) -> Wrapped(IVec2), - self Mul Raw(i32) -> Wrapped(IVec2), - self Rem self -> Wrapped(IVec2), - self Rem Raw(i32) -> Wrapped(IVec2), - self Rem Wrapped(IVec2) -> Wrapped(IVec2), - ) - + UnaryOps - ( - Neg self -> self - ) - lua impl - { - (MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}; - mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,i32)| {s.val_mut(|s| Ok(s[*idx] = val))?}; - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 3-dimensional vector. - glam::i32::IVec3 : - Clone + - Debug + - Methods - ( - ///Creates a new vector. - new(Raw(i32),Raw(i32),Raw(i32)) -> self, - - ///Creates a vector with all elements set to `v`. - splat(Raw(i32)) -> self, - - ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use - ///for each element of `self`. - /// - ///A true element in the mask uses the corresponding element from `if_true`, and false - ///uses the element from `if_false`. - select(Wrapped(BVec3),self,self) -> self, - - ///Creates a 4D vector from `self` and the given `w` value. - extend(self:Raw(i32)) -> Wrapped(IVec4), - - ///Creates a 2D vector from the `x` and `y` elements of `self`, discarding `z`. - /// - ///Truncation may also be performed by using [`self.xy()`][crate::swizzles::Vec3Swizzles::xy()]. - truncate(self:) -> Wrapped(IVec2), - - ///Computes the dot product of `self` and `rhs`. - dot(self:self) -> Raw(i32), - - ///Returns a vector where every component is the dot product of `self` and `rhs`. - dot_into_vec(self:self) -> self, - - ///Computes the cross product of `self` and `rhs`. - cross(self:self) -> self, - - ///Returns a vector containing the minimum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. - min(self:self) -> self, - - ///Returns a vector containing the maximum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. - max(self:self) -> self, - - ///Component-wise clamping of values, similar to [`i32::clamp`]. - /// - ///Each element in `min` must be less-or-equal to the corresponding element in `max`. - /// - ///# Panics - /// - ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. - clamp(self:self,self) -> self, - - ///Returns the horizontal minimum of `self`. - /// - ///In other words this computes `min(x, y, ..)`. - min_element(self:) -> Raw(i32), - - ///Returns the horizontal maximum of `self`. - /// - ///In other words this computes `max(x, y, ..)`. - max_element(self:) -> Raw(i32), - - ///Returns a vector mask containing the result of a `==` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all - ///elements. - cmpeq(self:self) -> Wrapped(BVec3), - - ///Returns a vector mask containing the result of a `!=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all - ///elements. - cmpne(self:self) -> Wrapped(BVec3), - - ///Returns a vector mask containing the result of a `>=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all - ///elements. - cmpge(self:self) -> Wrapped(BVec3), - - ///Returns a vector mask containing the result of a `>` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all - ///elements. - cmpgt(self:self) -> Wrapped(BVec3), - - ///Returns a vector mask containing the result of a `<=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all - ///elements. - cmple(self:self) -> Wrapped(BVec3), - - ///Returns a vector mask containing the result of a `<` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all - ///elements. - cmplt(self:self) -> Wrapped(BVec3), - - ///Returns a vector containing the absolute value of each element of `self`. - abs(self:) -> self, - - ///Returns a vector with elements representing the sign of `self`. - /// - /// - `0` if the number is zero - /// - `1` if the number is positive - /// - `-1` if the number is negative - signum(self:) -> self, - - ///Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of `self`. - /// - ///A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes - ///into the first lowest bit, element `y` into the second, etc. - is_negative_bitmask(self:) -> Raw(u32), - - ///Computes the squared length of `self`. - length_squared(self:) -> Raw(i32), - - ///Compute the squared euclidean distance between two points in space. - distance_squared(self:self) -> Raw(i32), - - ///Casts all elements of `self` to `f32`. - as_vec3(&self:) -> Wrapped(Vec3), - - ///Casts all elements of `self` to `f32`. - as_vec3a(&self:) -> Wrapped(Vec3A), - - ///Casts all elements of `self` to `f64`. - as_dvec3(&self:) -> Wrapped(DVec3), - - ///Casts all elements of `self` to `u32`. - as_uvec3(&self:) -> Wrapped(UVec3), - - ) - + Fields - ( - x: Raw(i32), - y: Raw(i32), - z: Raw(i32), - ) - + BinOps - ( - self Add Raw(i32) -> Wrapped(IVec3), - self Add Wrapped(IVec3) -> Wrapped(IVec3), - self Add self -> Wrapped(IVec3), - self Sub Raw(i32) -> Wrapped(IVec3), - self Sub self -> Wrapped(IVec3), - self Sub Wrapped(IVec3) -> Wrapped(IVec3), - self Div Raw(i32) -> Wrapped(IVec3), - self Div self -> Wrapped(IVec3), - self Div Wrapped(IVec3) -> Wrapped(IVec3), - self Mul Wrapped(IVec3) -> Wrapped(IVec3), - self Mul self -> Wrapped(IVec3), - self Mul Raw(i32) -> Wrapped(IVec3), - self Rem Raw(i32) -> Wrapped(IVec3), - self Rem Wrapped(IVec3) -> Wrapped(IVec3), - self Rem self -> Wrapped(IVec3), - ) - + UnaryOps - ( - Neg self -> self - ) - lua impl - { - (MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}; - mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,i32)| {s.val_mut(|s| Ok(s[*idx] = val))?}; - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 4-dimensional vector. - glam::i32::IVec4 : - Clone + - Debug + - Methods - ( - ///Creates a new vector. - new(Raw(i32),Raw(i32),Raw(i32),Raw(i32)) -> self, - - ///Creates a vector with all elements set to `v`. - splat(Raw(i32)) -> self, - - ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use - ///for each element of `self`. - /// - ///A true element in the mask uses the corresponding element from `if_true`, and false - ///uses the element from `if_false`. - select(Wrapped(BVec4),self,self) -> self, - - ///Creates a 2D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. - /// - ///Truncation to [`IVec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. - truncate(self:) -> Wrapped(IVec3), - - ///Computes the dot product of `self` and `rhs`. - dot(self:self) -> Raw(i32), - - ///Returns a vector where every component is the dot product of `self` and `rhs`. - dot_into_vec(self:self) -> self, - - ///Returns a vector containing the minimum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. - min(self:self) -> self, - - ///Returns a vector containing the maximum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. - max(self:self) -> self, - - ///Component-wise clamping of values, similar to [`i32::clamp`]. - /// - ///Each element in `min` must be less-or-equal to the corresponding element in `max`. - /// - ///# Panics - /// - ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. - clamp(self:self,self) -> self, - - ///Returns the horizontal minimum of `self`. - /// - ///In other words this computes `min(x, y, ..)`. - min_element(self:) -> Raw(i32), - - ///Returns the horizontal maximum of `self`. - /// - ///In other words this computes `max(x, y, ..)`. - max_element(self:) -> Raw(i32), - - ///Returns a vector mask containing the result of a `==` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all - ///elements. - cmpeq(self:self) -> Wrapped(BVec4), - - ///Returns a vector mask containing the result of a `!=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all - ///elements. - cmpne(self:self) -> Wrapped(BVec4), - - ///Returns a vector mask containing the result of a `>=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all - ///elements. - cmpge(self:self) -> Wrapped(BVec4), - - ///Returns a vector mask containing the result of a `>` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all - ///elements. - cmpgt(self:self) -> Wrapped(BVec4), - - ///Returns a vector mask containing the result of a `<=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all - ///elements. - cmple(self:self) -> Wrapped(BVec4), - - ///Returns a vector mask containing the result of a `<` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all - ///elements. - cmplt(self:self) -> Wrapped(BVec4), - - ///Returns a vector containing the absolute value of each element of `self`. - abs(self:) -> self, - - ///Returns a vector with elements representing the sign of `self`. - /// - /// - `0` if the number is zero - /// - `1` if the number is positive - /// - `-1` if the number is negative - signum(self:) -> self, - - ///Returns a bitmask with the lowest 4 bits set to the sign bits from the elements of `self`. - /// - ///A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes - ///into the first lowest bit, element `y` into the second, etc. - is_negative_bitmask(self:) -> Raw(u32), - - ///Computes the squared length of `self`. - length_squared(self:) -> Raw(i32), - - ///Compute the squared euclidean distance between two points in space. - distance_squared(self:self) -> Raw(i32), - - ///Casts all elements of `self` to `f32`. - as_vec4(&self:) -> Wrapped(Vec4), - - ///Casts all elements of `self` to `f64`. - as_dvec4(&self:) -> Wrapped(DVec4), - - ///Casts all elements of `self` to `u32`. - as_uvec4(&self:) -> Wrapped(UVec4), - - ) - + Fields - ( - x: Raw(i32), - y: Raw(i32), - z: Raw(i32), - w: Raw(i32), - ) - + BinOps - ( - self Add Wrapped(IVec4) -> Wrapped(IVec4), - self Add self -> Wrapped(IVec4), - self Add Raw(i32) -> Wrapped(IVec4), - self Sub self -> Wrapped(IVec4), - self Sub Wrapped(IVec4) -> Wrapped(IVec4), - self Sub Raw(i32) -> Wrapped(IVec4), - self Div self -> Wrapped(IVec4), - self Div Wrapped(IVec4) -> Wrapped(IVec4), - self Div Raw(i32) -> Wrapped(IVec4), - self Mul self -> Wrapped(IVec4), - self Mul Wrapped(IVec4) -> Wrapped(IVec4), - self Mul Raw(i32) -> Wrapped(IVec4), - self Rem Raw(i32) -> Wrapped(IVec4), - self Rem Wrapped(IVec4) -> Wrapped(IVec4), - self Rem self -> Wrapped(IVec4), - ) - + UnaryOps - ( - Neg self -> self - ) - lua impl - { - (MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}; - mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,i32)| {s.val_mut(|s| Ok(s[*idx] = val))?}; - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 2-dimensional vector. - glam::u32::UVec2 : - Clone + - Debug + - Methods - ( - ///Creates a new vector. - new(Raw(u32),Raw(u32)) -> self, - - ///Creates a vector with all elements set to `v`. - splat(Raw(u32)) -> self, - - ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use - ///for each element of `self`. - /// - ///A true element in the mask uses the corresponding element from `if_true`, and false - ///uses the element from `if_false`. - select(Wrapped(BVec2),self,self) -> self, - - ///Creates a 3D vector from `self` and the given `z` value. - extend(self:Raw(u32)) -> Wrapped(UVec3), - - ///Computes the dot product of `self` and `rhs`. - dot(self:self) -> Raw(u32), - - ///Returns a vector where every component is the dot product of `self` and `rhs`. - dot_into_vec(self:self) -> self, - - ///Returns a vector containing the minimum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. - min(self:self) -> self, - - ///Returns a vector containing the maximum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. - max(self:self) -> self, - - ///Component-wise clamping of values, similar to [`u32::clamp`]. - /// - ///Each element in `min` must be less-or-equal to the corresponding element in `max`. - /// - ///# Panics - /// - ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. - clamp(self:self,self) -> self, - - ///Returns the horizontal minimum of `self`. - /// - ///In other words this computes `min(x, y, ..)`. - min_element(self:) -> Raw(u32), - - ///Returns the horizontal maximum of `self`. - /// - ///In other words this computes `max(x, y, ..)`. - max_element(self:) -> Raw(u32), - - ///Returns a vector mask containing the result of a `==` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all - ///elements. - cmpeq(self:self) -> Wrapped(BVec2), - - ///Returns a vector mask containing the result of a `!=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all - ///elements. - cmpne(self:self) -> Wrapped(BVec2), - - ///Returns a vector mask containing the result of a `>=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all - ///elements. - cmpge(self:self) -> Wrapped(BVec2), - - ///Returns a vector mask containing the result of a `>` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all - ///elements. - cmpgt(self:self) -> Wrapped(BVec2), - - ///Returns a vector mask containing the result of a `<=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all - ///elements. - cmple(self:self) -> Wrapped(BVec2), - - ///Returns a vector mask containing the result of a `<` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all - ///elements. - cmplt(self:self) -> Wrapped(BVec2), - - ///Computes the squared length of `self`. - length_squared(self:) -> Raw(u32), - - ///Casts all elements of `self` to `f32`. - as_vec2(&self:) -> Wrapped(Vec2), - - ///Casts all elements of `self` to `f64`. - as_dvec2(&self:) -> Wrapped(DVec2), - - ///Casts all elements of `self` to `i32`. - as_ivec2(&self:) -> Wrapped(IVec2), - - ) - + Fields - ( - x: Raw(u32), - y: Raw(u32), - ) - + BinOps - ( - self Add Raw(u32) -> Wrapped(UVec2), - self Add Wrapped(UVec2) -> Wrapped(UVec2), - self Add self -> Wrapped(UVec2), - self Sub self -> Wrapped(UVec2), - self Sub Wrapped(UVec2) -> Wrapped(UVec2), - self Sub Raw(u32) -> Wrapped(UVec2), - self Div self -> Wrapped(UVec2), - self Div Raw(u32) -> Wrapped(UVec2), - self Div Wrapped(UVec2) -> Wrapped(UVec2), - self Mul Wrapped(UVec2) -> Wrapped(UVec2), - self Mul Raw(u32) -> Wrapped(UVec2), - self Mul self -> Wrapped(UVec2), - self Rem self -> Wrapped(UVec2), - self Rem Raw(u32) -> Wrapped(UVec2), - self Rem Wrapped(UVec2) -> Wrapped(UVec2), - ) - + UnaryOps - ( - ) - lua impl - { - (MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}; - mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,u32)| {s.val_mut(|s| Ok(s[*idx] = val))?}; - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 3-dimensional vector. - glam::u32::UVec3 : - Clone + - Debug + - Methods - ( - ///Creates a new vector. - new(Raw(u32),Raw(u32),Raw(u32)) -> self, - - ///Creates a vector with all elements set to `v`. - splat(Raw(u32)) -> self, - - ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use - ///for each element of `self`. - /// - ///A true element in the mask uses the corresponding element from `if_true`, and false - ///uses the element from `if_false`. - select(Wrapped(BVec3),self,self) -> self, - - ///Creates a 4D vector from `self` and the given `w` value. - extend(self:Raw(u32)) -> Wrapped(UVec4), - - ///Creates a 2D vector from the `x` and `y` elements of `self`, discarding `z`. - /// - ///Truncation may also be performed by using [`self.xy()`][crate::swizzles::Vec3Swizzles::xy()]. - truncate(self:) -> Wrapped(UVec2), - - ///Computes the dot product of `self` and `rhs`. - dot(self:self) -> Raw(u32), - - ///Returns a vector where every component is the dot product of `self` and `rhs`. - dot_into_vec(self:self) -> self, - - ///Computes the cross product of `self` and `rhs`. - cross(self:self) -> self, - - ///Returns a vector containing the minimum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. - min(self:self) -> self, - - ///Returns a vector containing the maximum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. - max(self:self) -> self, - - ///Component-wise clamping of values, similar to [`u32::clamp`]. - /// - ///Each element in `min` must be less-or-equal to the corresponding element in `max`. - /// - ///# Panics - /// - ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. - clamp(self:self,self) -> self, - - ///Returns the horizontal minimum of `self`. - /// - ///In other words this computes `min(x, y, ..)`. - min_element(self:) -> Raw(u32), - - ///Returns the horizontal maximum of `self`. - /// - ///In other words this computes `max(x, y, ..)`. - max_element(self:) -> Raw(u32), - - ///Returns a vector mask containing the result of a `==` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all - ///elements. - cmpeq(self:self) -> Wrapped(BVec3), - - ///Returns a vector mask containing the result of a `!=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all - ///elements. - cmpne(self:self) -> Wrapped(BVec3), - - ///Returns a vector mask containing the result of a `>=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all - ///elements. - cmpge(self:self) -> Wrapped(BVec3), - - ///Returns a vector mask containing the result of a `>` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all - ///elements. - cmpgt(self:self) -> Wrapped(BVec3), - - ///Returns a vector mask containing the result of a `<=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all - ///elements. - cmple(self:self) -> Wrapped(BVec3), - - ///Returns a vector mask containing the result of a `<` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all - ///elements. - cmplt(self:self) -> Wrapped(BVec3), - - ///Computes the squared length of `self`. - length_squared(self:) -> Raw(u32), - - ///Casts all elements of `self` to `f32`. - as_vec3(&self:) -> Wrapped(Vec3), - - ///Casts all elements of `self` to `f32`. - as_vec3a(&self:) -> Wrapped(Vec3A), - - ///Casts all elements of `self` to `f64`. - as_dvec3(&self:) -> Wrapped(DVec3), - - ///Casts all elements of `self` to `i32`. - as_ivec3(&self:) -> Wrapped(IVec3), - - ) - + Fields - ( - x: Raw(u32), - y: Raw(u32), - z: Raw(u32), - ) - + BinOps - ( - self Add Wrapped(UVec3) -> Wrapped(UVec3), - self Add Raw(u32) -> Wrapped(UVec3), - self Add self -> Wrapped(UVec3), - self Sub Wrapped(UVec3) -> Wrapped(UVec3), - self Sub Raw(u32) -> Wrapped(UVec3), - self Sub self -> Wrapped(UVec3), - self Div self -> Wrapped(UVec3), - self Div Raw(u32) -> Wrapped(UVec3), - self Div Wrapped(UVec3) -> Wrapped(UVec3), - self Mul Wrapped(UVec3) -> Wrapped(UVec3), - self Mul Raw(u32) -> Wrapped(UVec3), - self Mul self -> Wrapped(UVec3), - self Rem Raw(u32) -> Wrapped(UVec3), - self Rem self -> Wrapped(UVec3), - self Rem Wrapped(UVec3) -> Wrapped(UVec3), - ) - + UnaryOps - ( - ) - lua impl - { - (MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}; - mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,u32)| {s.val_mut(|s| Ok(s[*idx] = val))?}; - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 4-dimensional vector. - glam::u32::UVec4 : - Clone + - Debug + - Methods - ( - ///Creates a new vector. - new(Raw(u32),Raw(u32),Raw(u32),Raw(u32)) -> self, - - ///Creates a vector with all elements set to `v`. - splat(Raw(u32)) -> self, - - ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use - ///for each element of `self`. - /// - ///A true element in the mask uses the corresponding element from `if_true`, and false - ///uses the element from `if_false`. - select(Wrapped(BVec4),self,self) -> self, - - ///Creates a 2D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. - /// - ///Truncation to [`UVec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. - truncate(self:) -> Wrapped(UVec3), - - ///Computes the dot product of `self` and `rhs`. - dot(self:self) -> Raw(u32), - - ///Returns a vector where every component is the dot product of `self` and `rhs`. - dot_into_vec(self:self) -> self, - - ///Returns a vector containing the minimum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. - min(self:self) -> self, - - ///Returns a vector containing the maximum values for each element of `self` and `rhs`. - /// - ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. - max(self:self) -> self, - - ///Component-wise clamping of values, similar to [`u32::clamp`]. - /// - ///Each element in `min` must be less-or-equal to the corresponding element in `max`. - /// - ///# Panics - /// - ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. - clamp(self:self,self) -> self, - - ///Returns the horizontal minimum of `self`. - /// - ///In other words this computes `min(x, y, ..)`. - min_element(self:) -> Raw(u32), - - ///Returns the horizontal maximum of `self`. - /// - ///In other words this computes `max(x, y, ..)`. - max_element(self:) -> Raw(u32), - - ///Returns a vector mask containing the result of a `==` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all - ///elements. - cmpeq(self:self) -> Wrapped(BVec4), - - ///Returns a vector mask containing the result of a `!=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all - ///elements. - cmpne(self:self) -> Wrapped(BVec4), - - ///Returns a vector mask containing the result of a `>=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all - ///elements. - cmpge(self:self) -> Wrapped(BVec4), - - ///Returns a vector mask containing the result of a `>` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all - ///elements. - cmpgt(self:self) -> Wrapped(BVec4), - - ///Returns a vector mask containing the result of a `<=` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all - ///elements. - cmple(self:self) -> Wrapped(BVec4), - - ///Returns a vector mask containing the result of a `<` comparison for each element of - ///`self` and `rhs`. - /// - ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all - ///elements. - cmplt(self:self) -> Wrapped(BVec4), - - ///Computes the squared length of `self`. - length_squared(self:) -> Raw(u32), - - ///Casts all elements of `self` to `f32`. - as_vec4(&self:) -> Wrapped(Vec4), - - ///Casts all elements of `self` to `f64`. - as_dvec4(&self:) -> Wrapped(DVec4), - - ///Casts all elements of `self` to `i32`. - as_ivec4(&self:) -> Wrapped(IVec4), - - ) - + Fields - ( - x: Raw(u32), - y: Raw(u32), - z: Raw(u32), - w: Raw(u32), - ) - + BinOps - ( - self Add self -> Wrapped(UVec4), - self Add Wrapped(UVec4) -> Wrapped(UVec4), - self Add Raw(u32) -> Wrapped(UVec4), - self Sub self -> Wrapped(UVec4), - self Sub Wrapped(UVec4) -> Wrapped(UVec4), - self Sub Raw(u32) -> Wrapped(UVec4), - self Div self -> Wrapped(UVec4), - self Div Raw(u32) -> Wrapped(UVec4), - self Div Wrapped(UVec4) -> Wrapped(UVec4), - self Mul Wrapped(UVec4) -> Wrapped(UVec4), - self Mul self -> Wrapped(UVec4), - self Mul Raw(u32) -> Wrapped(UVec4), - self Rem self -> Wrapped(UVec4), - self Rem Raw(u32) -> Wrapped(UVec4), - self Rem Wrapped(UVec4) -> Wrapped(UVec4), - ) - + UnaryOps - ( - ) - lua impl - { - (MetaMethod::Index) => |_,s,idx: LuaIndex| {Ok(s.inner()?[*idx])}; - mut (MetaMethod::NewIndex) => |_,s,(idx,val): (LuaIndex,u32)| {s.val_mut(|s| Ok(s[*idx] = val))?}; - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 3x3 column major matrix. - /// - ///This 3x3 matrix type features convenience methods for creating and using linear and - ///affine transformations. If you are primarily dealing with 2D affine transformations the - ///[`Affine2`](crate::Affine2) type is much faster and more space efficient than - ///using a 3x3 matrix. - /// - ///Linear transformations including 3D rotation and scale can be created using methods - ///such as [`Self::from_diagonal()`], [`Self::from_quat()`], [`Self::from_axis_angle()`], - ///[`Self::from_rotation_x()`], [`Self::from_rotation_y()`], or - ///[`Self::from_rotation_z()`]. - /// - ///The resulting matrices can be use to transform 3D vectors using regular vector - ///multiplication. - /// - ///Affine transformations including 2D translation, rotation and scale can be created - ///using methods such as [`Self::from_translation()`], [`Self::from_angle()`], - ///[`Self::from_scale()`] and [`Self::from_scale_angle_translation()`]. - /// - ///The [`Self::transform_point2()`] and [`Self::transform_vector2()`] convenience methods - ///are provided for performing affine transforms on 2D vectors and points. These multiply - ///2D inputs as 3D vectors with an implicit `z` value of `1` for points and `0` for - ///vectors respectively. These methods assume that `Self` contains a valid affine - ///transform. - glam::f32::Mat3 : - Clone + - Debug + - Methods - ( - ///Creates a 3x3 matrix from three column vectors. - from_cols(Wrapped(Vec3),Wrapped(Vec3),Wrapped(Vec3)) -> self, - - ///Creates a 3x3 matrix with its diagonal set to `diagonal` and all other entries set to 0. - from_diagonal(Wrapped(Vec3)) -> self, - - ///Creates a 3x3 matrix from a 4x4 matrix, discarding the 4th row and column. - from_mat4(Wrapped(Mat4)) -> self, - - ///Creates a 3D rotation matrix from the given quaternion. - /// - ///# Panics - /// - ///Will panic if `rotation` is not normalized when `glam_assert` is enabled. - from_quat(Wrapped(Quat)) -> self, - - ///Creates a 3D rotation matrix from a normalized rotation `axis` and `angle` (in - ///radians). - /// - ///# Panics - /// - ///Will panic if `axis` is not normalized when `glam_assert` is enabled. - from_axis_angle(Wrapped(Vec3),Raw(f32)) -> self, - - ///Creates a 3D rotation matrix from the given euler rotation sequence and the angles (in - ///radians). - from_euler(Wrapped(EulerRot),Raw(f32),Raw(f32),Raw(f32)) -> self, - - ///Creates a 3D rotation matrix from `angle` (in radians) around the x axis. - from_rotation_x(Raw(f32)) -> self, - - ///Creates a 3D rotation matrix from `angle` (in radians) around the y axis. - from_rotation_y(Raw(f32)) -> self, - - ///Creates a 3D rotation matrix from `angle` (in radians) around the z axis. - from_rotation_z(Raw(f32)) -> self, - - ///Creates an affine transformation matrix from the given 2D `translation`. - /// - ///The resulting matrix can be used to transform 2D points and vectors. See - ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. - from_translation(Wrapped(Vec2)) -> self, - - ///Creates an affine transformation matrix from the given 2D rotation `angle` (in - ///radians). - /// - ///The resulting matrix can be used to transform 2D points and vectors. See - ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. - from_angle(Raw(f32)) -> self, - - ///Creates an affine transformation matrix from the given 2D `scale`, rotation `angle` (in - ///radians) and `translation`. - /// - ///The resulting matrix can be used to transform 2D points and vectors. See - ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. - from_scale_angle_translation(Wrapped(Vec2),Raw(f32),Wrapped(Vec2)) -> self, - - ///Creates an affine transformation matrix from the given non-uniform 2D `scale`. - /// - ///The resulting matrix can be used to transform 2D points and vectors. See - ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. - /// - ///# Panics - /// - ///Will panic if all elements of `scale` are zero when `glam_assert` is enabled. - from_scale(Wrapped(Vec2)) -> self, - - ///Creates an affine transformation matrix from the given 2x2 matrix. - /// - ///The resulting matrix can be used to transform 2D points and vectors. See - ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. - from_mat2(Wrapped(Mat2)) -> self, - - ///Returns the matrix column for the given `index`. - /// - ///# Panics - /// - ///Panics if `index` is greater than 2. - col(&self:Raw(usize)) -> Wrapped(Vec3), - - ///Returns the matrix row for the given `index`. - /// - ///# Panics - /// - ///Panics if `index` is greater than 2. - row(&self:Raw(usize)) -> Wrapped(Vec3), - - ///Returns `true` if, and only if, all elements are finite. - ///If any element is either `NaN`, positive or negative infinity, this will return `false`. - is_finite(&self:) -> Raw(bool), - - ///Returns `true` if any elements are `NaN`. - is_nan(&self:) -> Raw(bool), - - ///Returns the transpose of `self`. - transpose(&self:) -> self, - - ///Returns the determinant of `self`. - determinant(&self:) -> Raw(f32), - - ///Returns the inverse of `self`. - /// - ///If the matrix is not invertible the returned matrix will be invalid. - /// - ///# Panics - /// - ///Will panic if the determinant of `self` is zero when `glam_assert` is enabled. - inverse(&self:) -> self, - - ///Transforms the given 2D vector as a point. - /// - ///This is the equivalent of multiplying `rhs` as a 3D vector where `z` is `1`. - /// - ///This method assumes that `self` contains a valid affine transform. - /// - ///# Panics - /// - ///Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. - transform_point2(&self:Wrapped(Vec2)) -> Wrapped(Vec2), - - ///Rotates the given 2D vector. - /// - ///This is the equivalent of multiplying `rhs` as a 3D vector where `z` is `0`. - /// - ///This method assumes that `self` contains a valid affine transform. - /// - ///# Panics - /// - ///Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. - transform_vector2(&self:Wrapped(Vec2)) -> Wrapped(Vec2), - - ///Transforms a 3D vector. - mul_vec3(&self:Wrapped(Vec3)) -> Wrapped(Vec3), - - ///Transforms a [`Vec3A`]. - mul_vec3a(&self:Wrapped(Vec3A)) -> Wrapped(Vec3A), - - ///Multiplies two 3x3 matrices. - mul_mat3(&self:&self) -> self, - - ///Adds two 3x3 matrices. - add_mat3(&self:&self) -> self, - - ///Subtracts two 3x3 matrices. - sub_mat3(&self:&self) -> self, - - ///Multiplies a 3x3 matrix by a scalar. - mul_scalar(&self:Raw(f32)) -> self, - - ///Returns true if the absolute difference of all elements between `self` and `rhs` - ///is less than or equal to `max_abs_diff`. - /// - ///This can be used to compare if two matrices contain similar elements. It works best - ///when comparing with a known value. The `max_abs_diff` that should be used used - ///depends on the values being compared against. - /// - ///For more see - ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - abs_diff_eq(&self:self,Raw(f32)) -> Raw(bool), - - as_dmat3(&self:) -> Wrapped(DMat3), - - ) - + Fields - ( - x_axis: Wrapped(Vec3), - y_axis: Wrapped(Vec3), - z_axis: Wrapped(Vec3), - ) - + BinOps - ( - self Add self -> Wrapped(Mat3), - self Sub self -> Wrapped(Mat3), - self Mul Wrapped(Mat3) -> Wrapped(Mat3), - self Mul Wrapped(Affine2) -> Wrapped(Mat3), - self Mul Raw(f32) -> Wrapped(Mat3), - self Mul self -> Wrapped(Mat3), - self Mul Wrapped(Vec3) -> Wrapped(Vec3), - self Mul Wrapped(Vec3A) -> Wrapped(Vec3A), - ) - + UnaryOps - ( - Neg self -> self - ) - lua impl - { - - mut (MetaMethod::Index) => |ctx,s,idx : LuaIndex| { - Ok(LuaVec3::new_ref( - s.script_ref(ctx.get_world()?).sub_ref(ReflectPathElem::SubReflectionIndexed{ - label:"col", - index: *idx, - get: |idx,ref_| Err(ReflectionError::InsufficientProvenance{ - path: "".to_owned(), - msg: "Cannot get column of matrix with immutable reference".to_owned() - }), - get_mut: |idx, ref_| { - if ref_.is::(){ - Ok(ref_.downcast_mut::() - .unwrap() - .col_mut(idx)) - } else { - Err(ReflectionError::CannotDowncast{from: ref_.type_name().to_owned().into(), to:"Mat3".into()}) - } - } - }) - ) - ) - } -; - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 2x2 column major matrix. - /// - ///SIMD vector types are used for storage on supported platforms. - /// - ///This type is 16 byte aligned. - glam::f32::Mat2 : - Clone + - Debug + - Methods - ( - ///Creates a 2x2 matrix from two column vectors. - from_cols(Wrapped(Vec2),Wrapped(Vec2)) -> self, - - ///Creates a 2x2 matrix with its diagonal set to `diagonal` and all other entries set to 0. - from_diagonal(Wrapped(Vec2)) -> self, - - ///Creates a 2x2 matrix containing the combining non-uniform `scale` and rotation of - ///`angle` (in radians). - from_scale_angle(Wrapped(Vec2),Raw(f32)) -> self, - - ///Creates a 2x2 matrix containing a rotation of `angle` (in radians). - from_angle(Raw(f32)) -> self, - - ///Creates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column. - from_mat3(Wrapped(Mat3)) -> self, - - ///Creates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column. - from_mat3a(Wrapped(Mat3A)) -> self, - - ///Returns the matrix column for the given `index`. - /// - ///# Panics - /// - ///Panics if `index` is greater than 1. - col(&self:Raw(usize)) -> Wrapped(Vec2), - - ///Returns the matrix row for the given `index`. - /// - ///# Panics - /// - ///Panics if `index` is greater than 1. - row(&self:Raw(usize)) -> Wrapped(Vec2), - - ///Returns `true` if, and only if, all elements are finite. - ///If any element is either `NaN`, positive or negative infinity, this will return `false`. - is_finite(&self:) -> Raw(bool), - - ///Returns `true` if any elements are `NaN`. - is_nan(&self:) -> Raw(bool), - - ///Returns the transpose of `self`. - transpose(&self:) -> self, - - ///Returns the determinant of `self`. - determinant(&self:) -> Raw(f32), - - ///Returns the inverse of `self`. - /// - ///If the matrix is not invertible the returned matrix will be invalid. - /// - ///# Panics - /// - ///Will panic if the determinant of `self` is zero when `glam_assert` is enabled. - inverse(&self:) -> self, - - ///Transforms a 2D vector. - mul_vec2(&self:Wrapped(Vec2)) -> Wrapped(Vec2), - - ///Multiplies two 2x2 matrices. - mul_mat2(&self:&self) -> self, - - ///Adds two 2x2 matrices. - add_mat2(&self:&self) -> self, - - ///Subtracts two 2x2 matrices. - sub_mat2(&self:&self) -> self, - - ///Multiplies a 2x2 matrix by a scalar. - mul_scalar(&self:Raw(f32)) -> self, - - ///Returns true if the absolute difference of all elements between `self` and `rhs` - ///is less than or equal to `max_abs_diff`. - /// - ///This can be used to compare if two matrices contain similar elements. It works best - ///when comparing with a known value. The `max_abs_diff` that should be used used - ///depends on the values being compared against. - /// - ///For more see - ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - abs_diff_eq(&self:self,Raw(f32)) -> Raw(bool), - - as_dmat2(&self:) -> Wrapped(DMat2), - - ) - + Fields - ( - ) - + BinOps - ( - self Add self -> Wrapped(Mat2), - self Sub self -> Wrapped(Mat2), - self Mul Wrapped(Vec2) -> Wrapped(Vec2), - self Mul Wrapped(Mat2) -> Wrapped(Mat2), - self Mul Raw(f32) -> Wrapped(Mat2), - self Mul self -> Wrapped(Mat2), - ) - + UnaryOps - ( - Neg self -> self - ) - lua impl - { - - mut (MetaMethod::Index) => |ctx,s,idx : LuaIndex| { - Ok(LuaVec2::new_ref( - s.script_ref(ctx.get_world()?).sub_ref(ReflectPathElem::SubReflectionIndexed{ - label:"col", - index: *idx, - get: |idx,ref_| Err(ReflectionError::InsufficientProvenance{ - path: "".to_owned(), - msg: "Cannot get column of matrix with immutable reference".to_owned() - }), - get_mut: |idx, ref_| { - if ref_.is::(){ - Ok(ref_.downcast_mut::() - .unwrap() - .col_mut(idx)) - } else { - Err(ReflectionError::CannotDowncast{from: ref_.type_name().to_owned().into(), to:"Mat2".into()}) - } - } - }) - ) - ) - } -; - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 3x3 column major matrix. - /// - ///This 3x3 matrix type features convenience methods for creating and using linear and - ///affine transformations. If you are primarily dealing with 2D affine transformations the - ///[`Affine2`](crate::Affine2) type is much faster and more space efficient than - ///using a 3x3 matrix. - /// - ///Linear transformations including 3D rotation and scale can be created using methods - ///such as [`Self::from_diagonal()`], [`Self::from_quat()`], [`Self::from_axis_angle()`], - ///[`Self::from_rotation_x()`], [`Self::from_rotation_y()`], or - ///[`Self::from_rotation_z()`]. - /// - ///The resulting matrices can be use to transform 3D vectors using regular vector - ///multiplication. - /// - ///Affine transformations including 2D translation, rotation and scale can be created - ///using methods such as [`Self::from_translation()`], [`Self::from_angle()`], - ///[`Self::from_scale()`] and [`Self::from_scale_angle_translation()`]. - /// - ///The [`Self::transform_point2()`] and [`Self::transform_vector2()`] convenience methods - ///are provided for performing affine transforms on 2D vectors and points. These multiply - ///2D inputs as 3D vectors with an implicit `z` value of `1` for points and `0` for - ///vectors respectively. These methods assume that `Self` contains a valid affine - ///transform. - glam::f32::Mat3A : - Clone + - Debug + - Methods - ( - ///Creates a 3x3 matrix from three column vectors. - from_cols(Wrapped(Vec3A),Wrapped(Vec3A),Wrapped(Vec3A)) -> self, - - ///Creates a 3x3 matrix with its diagonal set to `diagonal` and all other entries set to 0. - from_diagonal(Wrapped(Vec3)) -> self, - - ///Creates a 3x3 matrix from a 4x4 matrix, discarding the 4th row and column. - from_mat4(Wrapped(Mat4)) -> self, - - ///Creates a 3D rotation matrix from the given quaternion. - /// - ///# Panics - /// - ///Will panic if `rotation` is not normalized when `glam_assert` is enabled. - from_quat(Wrapped(Quat)) -> self, - - ///Creates a 3D rotation matrix from a normalized rotation `axis` and `angle` (in - ///radians). - /// - ///# Panics - /// - ///Will panic if `axis` is not normalized when `glam_assert` is enabled. - from_axis_angle(Wrapped(Vec3),Raw(f32)) -> self, - - ///Creates a 3D rotation matrix from the given euler rotation sequence and the angles (in - ///radians). - from_euler(Wrapped(EulerRot),Raw(f32),Raw(f32),Raw(f32)) -> self, - - ///Creates a 3D rotation matrix from `angle` (in radians) around the x axis. - from_rotation_x(Raw(f32)) -> self, - - ///Creates a 3D rotation matrix from `angle` (in radians) around the y axis. - from_rotation_y(Raw(f32)) -> self, - - ///Creates a 3D rotation matrix from `angle` (in radians) around the z axis. - from_rotation_z(Raw(f32)) -> self, - - ///Creates an affine transformation matrix from the given 2D `translation`. - /// - ///The resulting matrix can be used to transform 2D points and vectors. See - ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. - from_translation(Wrapped(Vec2)) -> self, - - ///Creates an affine transformation matrix from the given 2D rotation `angle` (in - ///radians). - /// - ///The resulting matrix can be used to transform 2D points and vectors. See - ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. - from_angle(Raw(f32)) -> self, - - ///Creates an affine transformation matrix from the given 2D `scale`, rotation `angle` (in - ///radians) and `translation`. - /// - ///The resulting matrix can be used to transform 2D points and vectors. See - ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. - from_scale_angle_translation(Wrapped(Vec2),Raw(f32),Wrapped(Vec2)) -> self, - - ///Creates an affine transformation matrix from the given non-uniform 2D `scale`. - /// - ///The resulting matrix can be used to transform 2D points and vectors. See - ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. - /// - ///# Panics - /// - ///Will panic if all elements of `scale` are zero when `glam_assert` is enabled. - from_scale(Wrapped(Vec2)) -> self, - - ///Creates an affine transformation matrix from the given 2x2 matrix. - /// - ///The resulting matrix can be used to transform 2D points and vectors. See - ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. - from_mat2(Wrapped(Mat2)) -> self, - - ///Returns the matrix column for the given `index`. - /// - ///# Panics - /// - ///Panics if `index` is greater than 2. - col(&self:Raw(usize)) -> Wrapped(Vec3A), - - ///Returns the matrix row for the given `index`. - /// - ///# Panics - /// - ///Panics if `index` is greater than 2. - row(&self:Raw(usize)) -> Wrapped(Vec3A), - - ///Returns `true` if, and only if, all elements are finite. - ///If any element is either `NaN`, positive or negative infinity, this will return `false`. - is_finite(&self:) -> Raw(bool), - - ///Returns `true` if any elements are `NaN`. - is_nan(&self:) -> Raw(bool), - - ///Returns the transpose of `self`. - transpose(&self:) -> self, - - ///Returns the determinant of `self`. - determinant(&self:) -> Raw(f32), - - ///Returns the inverse of `self`. - /// - ///If the matrix is not invertible the returned matrix will be invalid. - /// - ///# Panics - /// - ///Will panic if the determinant of `self` is zero when `glam_assert` is enabled. - inverse(&self:) -> self, - - ///Transforms the given 2D vector as a point. - /// - ///This is the equivalent of multiplying `rhs` as a 3D vector where `z` is `1`. - /// - ///This method assumes that `self` contains a valid affine transform. - /// - ///# Panics - /// - ///Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. - transform_point2(&self:Wrapped(Vec2)) -> Wrapped(Vec2), - - ///Rotates the given 2D vector. - /// - ///This is the equivalent of multiplying `rhs` as a 3D vector where `z` is `0`. - /// - ///This method assumes that `self` contains a valid affine transform. - /// - ///# Panics - /// - ///Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. - transform_vector2(&self:Wrapped(Vec2)) -> Wrapped(Vec2), - - ///Transforms a 3D vector. - mul_vec3(&self:Wrapped(Vec3)) -> Wrapped(Vec3), - - ///Transforms a [`Vec3A`]. - mul_vec3a(&self:Wrapped(Vec3A)) -> Wrapped(Vec3A), - - ///Multiplies two 3x3 matrices. - mul_mat3(&self:&self) -> self, - - ///Adds two 3x3 matrices. - add_mat3(&self:&self) -> self, - - ///Subtracts two 3x3 matrices. - sub_mat3(&self:&self) -> self, - - ///Multiplies a 3x3 matrix by a scalar. - mul_scalar(&self:Raw(f32)) -> self, - - ///Returns true if the absolute difference of all elements between `self` and `rhs` - ///is less than or equal to `max_abs_diff`. - /// - ///This can be used to compare if two matrices contain similar elements. It works best - ///when comparing with a known value. The `max_abs_diff` that should be used used - ///depends on the values being compared against. - /// - ///For more see - ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - abs_diff_eq(&self:self,Raw(f32)) -> Raw(bool), - - as_dmat3(&self:) -> Wrapped(DMat3), - - ) - + Fields - ( - x_axis: Wrapped(Vec3A), - y_axis: Wrapped(Vec3A), - z_axis: Wrapped(Vec3A), - ) - + BinOps - ( - self Add self -> Wrapped(Mat3A), - self Sub self -> Wrapped(Mat3A), - self Mul Wrapped(Mat3A) -> Wrapped(Mat3A), - self Mul Wrapped(Affine2) -> Wrapped(Mat3A), - self Mul Wrapped(Vec3) -> Wrapped(Vec3), - self Mul Raw(f32) -> Wrapped(Mat3A), - self Mul self -> Wrapped(Mat3A), - self Mul Wrapped(Vec3A) -> Wrapped(Vec3A), - ) - + UnaryOps - ( - Neg self -> self - ) - lua impl - { - - mut (MetaMethod::Index) => |ctx,s,idx : LuaIndex| { - Ok(LuaVec3A::new_ref( - s.script_ref(ctx.get_world()?).sub_ref(ReflectPathElem::SubReflectionIndexed{ - label:"col", - index: *idx, - get: |idx,ref_| Err(ReflectionError::InsufficientProvenance{ - path: "".to_owned(), - msg: "Cannot get column of matrix with immutable reference".to_owned() - }), - get_mut: |idx, ref_| { - if ref_.is::(){ - Ok(ref_.downcast_mut::() - .unwrap() - .col_mut(idx)) - } else { - Err(ReflectionError::CannotDowncast{from: ref_.type_name().to_owned().into(), to:"Mat3A".into()}) - } - } - }) - ) - ) - } -; - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 4x4 column major matrix. - /// - ///This 4x4 matrix type features convenience methods for creating and using affine transforms and - ///perspective projections. If you are primarily dealing with 3D affine transformations - ///considering using [`Affine3A`](crate::Affine3A) which is faster than a 4x4 matrix - ///for some affine operations. - /// - ///Affine transformations including 3D translation, rotation and scale can be created - ///using methods such as [`Self::from_translation()`], [`Self::from_quat()`], - ///[`Self::from_scale()`] and [`Self::from_scale_rotation_translation()`]. - /// - ///Orthographic projections can be created using the methods [`Self::orthographic_lh()`] for - ///left-handed coordinate systems and [`Self::orthographic_rh()`] for right-handed - ///systems. The resulting matrix is also an affine transformation. - /// - ///The [`Self::transform_point3()`] and [`Self::transform_vector3()`] convenience methods - ///are provided for performing affine transformations on 3D vectors and points. These - ///multiply 3D inputs as 4D vectors with an implicit `w` value of `1` for points and `0` - ///for vectors respectively. These methods assume that `Self` contains a valid affine - ///transform. - /// - ///Perspective projections can be created using methods such as - ///[`Self::perspective_lh()`], [`Self::perspective_infinite_lh()`] and - ///[`Self::perspective_infinite_reverse_lh()`] for left-handed co-ordinate systems and - ///[`Self::perspective_rh()`], [`Self::perspective_infinite_rh()`] and - ///[`Self::perspective_infinite_reverse_rh()`] for right-handed co-ordinate systems. - /// - ///The resulting perspective project can be use to transform 3D vectors as points with - ///perspective correction using the [`Self::project_point3()`] convenience method. - glam::f32::Mat4 : - Clone + - Debug + - Methods - ( - ///Creates a 4x4 matrix from four column vectors. - from_cols(Wrapped(Vec4),Wrapped(Vec4),Wrapped(Vec4),Wrapped(Vec4)) -> self, - - ///Creates a 4x4 matrix with its diagonal set to `diagonal` and all other entries set to 0. - from_diagonal(Wrapped(Vec4)) -> self, - - ///Creates an affine transformation matrix from the given 3D `scale`, `rotation` and - ///`translation`. - /// - ///The resulting matrix can be used to transform 3D points and vectors. See - ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. - /// - ///# Panics - /// - ///Will panic if `rotation` is not normalized when `glam_assert` is enabled. - from_scale_rotation_translation(Wrapped(Vec3),Wrapped(Quat),Wrapped(Vec3)) -> self, - - ///Creates an affine transformation matrix from the given 3D `translation`. - /// - ///The resulting matrix can be used to transform 3D points and vectors. See - ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. - /// - ///# Panics - /// - ///Will panic if `rotation` is not normalized when `glam_assert` is enabled. - from_rotation_translation(Wrapped(Quat),Wrapped(Vec3)) -> self, - - ///Creates an affine transformation matrix from the given `rotation` quaternion. - /// - ///The resulting matrix can be used to transform 3D points and vectors. See - ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. - /// - ///# Panics - /// - ///Will panic if `rotation` is not normalized when `glam_assert` is enabled. - from_quat(Wrapped(Quat)) -> self, - - ///Creates an affine transformation matrix from the given 3x3 linear transformation - ///matrix. - /// - ///The resulting matrix can be used to transform 3D points and vectors. See - ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. - from_mat3(Wrapped(Mat3)) -> self, - - ///Creates an affine transformation matrix from the given 3x3 linear transformation - ///matrix. - /// - ///The resulting matrix can be used to transform 3D points and vectors. See - ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. - from_mat3a(Wrapped(Mat3A)) -> self, - - ///Creates an affine transformation matrix from the given 3D `translation`. - /// - ///The resulting matrix can be used to transform 3D points and vectors. See - ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. - from_translation(Wrapped(Vec3)) -> self, - - ///Creates an affine transformation matrix containing a 3D rotation around a normalized - ///rotation `axis` of `angle` (in radians). - /// - ///The resulting matrix can be used to transform 3D points and vectors. See - ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. - /// - ///# Panics - /// - ///Will panic if `axis` is not normalized when `glam_assert` is enabled. - from_axis_angle(Wrapped(Vec3),Raw(f32)) -> self, - - ///Creates a affine transformation matrix containing a rotation from the given euler - ///rotation sequence and angles (in radians). - /// - ///The resulting matrix can be used to transform 3D points and vectors. See - ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. - from_euler(Wrapped(EulerRot),Raw(f32),Raw(f32),Raw(f32)) -> self, - - ///Creates an affine transformation matrix containing a 3D rotation around the x axis of - ///`angle` (in radians). - /// - ///The resulting matrix can be used to transform 3D points and vectors. See - ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. - from_rotation_x(Raw(f32)) -> self, - - ///Creates an affine transformation matrix containing a 3D rotation around the y axis of - ///`angle` (in radians). - /// - ///The resulting matrix can be used to transform 3D points and vectors. See - ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. - from_rotation_y(Raw(f32)) -> self, - - ///Creates an affine transformation matrix containing a 3D rotation around the z axis of - ///`angle` (in radians). - /// - ///The resulting matrix can be used to transform 3D points and vectors. See - ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. - from_rotation_z(Raw(f32)) -> self, - - ///Creates an affine transformation matrix containing the given 3D non-uniform `scale`. - /// - ///The resulting matrix can be used to transform 3D points and vectors. See - ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. - /// - ///# Panics - /// - ///Will panic if all elements of `scale` are zero when `glam_assert` is enabled. - from_scale(Wrapped(Vec3)) -> self, - - ///Returns the matrix column for the given `index`. - /// - ///# Panics - /// - ///Panics if `index` is greater than 3. - col(&self:Raw(usize)) -> Wrapped(Vec4), - - ///Returns the matrix row for the given `index`. - /// - ///# Panics - /// - ///Panics if `index` is greater than 3. - row(&self:Raw(usize)) -> Wrapped(Vec4), - - ///Returns `true` if, and only if, all elements are finite. - ///If any element is either `NaN`, positive or negative infinity, this will return `false`. - is_finite(&self:) -> Raw(bool), - - ///Returns `true` if any elements are `NaN`. - is_nan(&self:) -> Raw(bool), - - ///Returns the transpose of `self`. - transpose(&self:) -> self, - - ///Returns the determinant of `self`. - determinant(&self:) -> Raw(f32), - - ///Returns the inverse of `self`. - /// - ///If the matrix is not invertible the returned matrix will be invalid. - /// - ///# Panics - /// - ///Will panic if the determinant of `self` is zero when `glam_assert` is enabled. - inverse(&self:) -> self, - - ///Creates a left-handed view matrix using a camera position, an up direction, and a facing - ///direction. - /// - ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. - look_to_lh(Wrapped(Vec3),Wrapped(Vec3),Wrapped(Vec3)) -> self, - - ///Creates a right-handed view matrix using a camera position, an up direction, and a facing - ///direction. - /// - ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. - look_to_rh(Wrapped(Vec3),Wrapped(Vec3),Wrapped(Vec3)) -> self, - - ///Creates a left-handed view matrix using a camera position, an up direction, and a focal - ///point. - ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. - /// - ///# Panics - /// - ///Will panic if `up` is not normalized when `glam_assert` is enabled. - look_at_lh(Wrapped(Vec3),Wrapped(Vec3),Wrapped(Vec3)) -> self, - - ///Creates a right-handed view matrix using a camera position, an up direction, and a focal - ///point. - ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. - /// - ///# Panics - /// - ///Will panic if `up` is not normalized when `glam_assert` is enabled. - look_at_rh(Wrapped(Vec3),Wrapped(Vec3),Wrapped(Vec3)) -> self, - - ///Creates a right-handed perspective projection matrix with [-1,1] depth range. - ///This is the same as the OpenGL `gluPerspective` function. - ///See - perspective_rh_gl(Raw(f32),Raw(f32),Raw(f32),Raw(f32)) -> self, - - ///Creates a left-handed perspective projection matrix with `[0,1]` depth range. - /// - ///# Panics - /// - ///Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is - ///enabled. - perspective_lh(Raw(f32),Raw(f32),Raw(f32),Raw(f32)) -> self, - - ///Creates a right-handed perspective projection matrix with `[0,1]` depth range. - /// - ///# Panics - /// - ///Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is - ///enabled. - perspective_rh(Raw(f32),Raw(f32),Raw(f32),Raw(f32)) -> self, - - ///Creates an infinite left-handed perspective projection matrix with `[0,1]` depth range. - /// - ///# Panics - /// - ///Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. - perspective_infinite_lh(Raw(f32),Raw(f32),Raw(f32)) -> self, - - ///Creates an infinite left-handed perspective projection matrix with `[0,1]` depth range. - /// - ///# Panics - /// - ///Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. - perspective_infinite_reverse_lh(Raw(f32),Raw(f32),Raw(f32)) -> self, - - ///Creates an infinite right-handed perspective projection matrix with - ///`[0,1]` depth range. - perspective_infinite_rh(Raw(f32),Raw(f32),Raw(f32)) -> self, - - ///Creates an infinite reverse right-handed perspective projection matrix - ///with `[0,1]` depth range. - perspective_infinite_reverse_rh(Raw(f32),Raw(f32),Raw(f32)) -> self, - - ///Creates a right-handed orthographic projection matrix with `[-1,1]` depth - ///range. This is the same as the OpenGL `glOrtho` function in OpenGL. - ///See - /// - orthographic_rh_gl(Raw(f32),Raw(f32),Raw(f32),Raw(f32),Raw(f32),Raw(f32)) -> self, - - ///Creates a left-handed orthographic projection matrix with `[0,1]` depth range. - orthographic_lh(Raw(f32),Raw(f32),Raw(f32),Raw(f32),Raw(f32),Raw(f32)) -> self, - - ///Creates a right-handed orthographic projection matrix with `[0,1]` depth range. - orthographic_rh(Raw(f32),Raw(f32),Raw(f32),Raw(f32),Raw(f32),Raw(f32)) -> self, - - ///Transforms the given 3D vector as a point, applying perspective correction. - /// - ///This is the equivalent of multiplying the 3D vector as a 4D vector where `w` is `1.0`. - ///The perspective divide is performed meaning the resulting 3D vector is divided by `w`. - /// - ///This method assumes that `self` contains a projective transform. - project_point3(&self:Wrapped(Vec3)) -> Wrapped(Vec3), - - ///Transforms the given 3D vector as a point. - /// - ///This is the equivalent of multiplying the 3D vector as a 4D vector where `w` is - ///`1.0`. - /// - ///This method assumes that `self` contains a valid affine transform. It does not perform - ///a persective divide, if `self` contains a perspective transform, or if you are unsure, - ///the [`Self::project_point3()`] method should be used instead. - /// - ///# Panics - /// - ///Will panic if the 3rd row of `self` is not `(0, 0, 0, 1)` when `glam_assert` is enabled. - transform_point3(&self:Wrapped(Vec3)) -> Wrapped(Vec3), - - ///Transforms the give 3D vector as a direction. - /// - ///This is the equivalent of multiplying the 3D vector as a 4D vector where `w` is - ///`0.0`. - /// - ///This method assumes that `self` contains a valid affine transform. - /// - ///# Panics - /// - ///Will panic if the 3rd row of `self` is not `(0, 0, 0, 1)` when `glam_assert` is enabled. - transform_vector3(&self:Wrapped(Vec3)) -> Wrapped(Vec3), - - ///Transforms the given [`Vec3A`] as 3D point. - /// - ///This is the equivalent of multiplying the [`Vec3A`] as a 4D vector where `w` is `1.0`. - transform_point3a(&self:Wrapped(Vec3A)) -> Wrapped(Vec3A), - - ///Transforms the give [`Vec3A`] as 3D vector. - /// - ///This is the equivalent of multiplying the [`Vec3A`] as a 4D vector where `w` is `0.0`. - transform_vector3a(&self:Wrapped(Vec3A)) -> Wrapped(Vec3A), - - ///Transforms a 4D vector. - mul_vec4(&self:Wrapped(Vec4)) -> Wrapped(Vec4), - - ///Multiplies two 4x4 matrices. - mul_mat4(&self:&self) -> self, - - ///Adds two 4x4 matrices. - add_mat4(&self:&self) -> self, - - ///Subtracts two 4x4 matrices. - sub_mat4(&self:&self) -> self, - - ///Multiplies a 4x4 matrix by a scalar. - mul_scalar(&self:Raw(f32)) -> self, - - ///Returns true if the absolute difference of all elements between `self` and `rhs` - ///is less than or equal to `max_abs_diff`. - /// - ///This can be used to compare if two matrices contain similar elements. It works best - ///when comparing with a known value. The `max_abs_diff` that should be used used - ///depends on the values being compared against. - /// - ///For more see - ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - abs_diff_eq(&self:self,Raw(f32)) -> Raw(bool), - - as_dmat4(&self:) -> Wrapped(DMat4), - - ) - + Fields - ( - x_axis: Wrapped(Vec4), - y_axis: Wrapped(Vec4), - z_axis: Wrapped(Vec4), - w_axis: Wrapped(Vec4), - ) - + BinOps - ( - self Add self -> Wrapped(Mat4), - self Sub self -> Wrapped(Mat4), - self Mul self -> Wrapped(Mat4), - self Mul Raw(f32) -> Wrapped(Mat4), - self Mul Wrapped(Mat4) -> Wrapped(Mat4), - self Mul Wrapped(Affine3A) -> Wrapped(Mat4), - self Mul Wrapped(Vec4) -> Wrapped(Vec4), - ) - + UnaryOps - ( - Neg self -> self - ) - lua impl - { - - mut (MetaMethod::Index) => |ctx,s,idx : LuaIndex| { - Ok(LuaVec4::new_ref( - s.script_ref(ctx.get_world()?).sub_ref(ReflectPathElem::SubReflectionIndexed{ - label:"col", - index: *idx, - get: |idx,ref_| Err(ReflectionError::InsufficientProvenance{ - path: "".to_owned(), - msg: "Cannot get column of matrix with immutable reference".to_owned() - }), - get_mut: |idx, ref_| { - if ref_.is::(){ - Ok(ref_.downcast_mut::() - .unwrap() - .col_mut(idx)) - } else { - Err(ReflectionError::CannotDowncast{from: ref_.type_name().to_owned().into(), to:"Mat4".into()}) - } - } - }) - ) - ) - } -; - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 2x2 column major matrix. - glam::f64::DMat2 : - Clone + - Debug + - Methods - ( - ///Creates a 2x2 matrix from two column vectors. - from_cols(Wrapped(DVec2),Wrapped(DVec2)) -> self, - - ///Creates a 2x2 matrix with its diagonal set to `diagonal` and all other entries set to 0. - from_diagonal(Wrapped(DVec2)) -> self, - - ///Creates a 2x2 matrix containing the combining non-uniform `scale` and rotation of - ///`angle` (in radians). - from_scale_angle(Wrapped(DVec2),Raw(f64)) -> self, - - ///Creates a 2x2 matrix containing a rotation of `angle` (in radians). - from_angle(Raw(f64)) -> self, - - ///Creates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column. - from_mat3(Wrapped(DMat3)) -> self, - - ///Returns the matrix column for the given `index`. - /// - ///# Panics - /// - ///Panics if `index` is greater than 1. - col(&self:Raw(usize)) -> Wrapped(DVec2), - - ///Returns the matrix row for the given `index`. - /// - ///# Panics - /// - ///Panics if `index` is greater than 1. - row(&self:Raw(usize)) -> Wrapped(DVec2), - - ///Returns `true` if, and only if, all elements are finite. - ///If any element is either `NaN`, positive or negative infinity, this will return `false`. - is_finite(&self:) -> Raw(bool), - - ///Returns `true` if any elements are `NaN`. - is_nan(&self:) -> Raw(bool), - - ///Returns the transpose of `self`. - transpose(&self:) -> self, - - ///Returns the determinant of `self`. - determinant(&self:) -> Raw(f64), - - ///Returns the inverse of `self`. - /// - ///If the matrix is not invertible the returned matrix will be invalid. - /// - ///# Panics - /// - ///Will panic if the determinant of `self` is zero when `glam_assert` is enabled. - inverse(&self:) -> self, - - ///Transforms a 2D vector. - mul_vec2(&self:Wrapped(DVec2)) -> Wrapped(DVec2), - - ///Multiplies two 2x2 matrices. - mul_mat2(&self:&self) -> self, - - ///Adds two 2x2 matrices. - add_mat2(&self:&self) -> self, - - ///Subtracts two 2x2 matrices. - sub_mat2(&self:&self) -> self, - - ///Multiplies a 2x2 matrix by a scalar. - mul_scalar(&self:Raw(f64)) -> self, - - ///Returns true if the absolute difference of all elements between `self` and `rhs` - ///is less than or equal to `max_abs_diff`. - /// - ///This can be used to compare if two matrices contain similar elements. It works best - ///when comparing with a known value. The `max_abs_diff` that should be used used - ///depends on the values being compared against. - /// - ///For more see - ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - abs_diff_eq(&self:self,Raw(f64)) -> Raw(bool), - - as_mat2(&self:) -> Wrapped(Mat2), - - ) - + Fields - ( - x_axis: Wrapped(DVec2), - y_axis: Wrapped(DVec2), - ) - + BinOps - ( - self Add self -> Wrapped(DMat2), - self Sub self -> Wrapped(DMat2), - self Mul Raw(f64) -> Wrapped(DMat2), - self Mul Wrapped(DVec2) -> Wrapped(DVec2), - self Mul self -> Wrapped(DMat2), - self Mul Wrapped(DMat2) -> Wrapped(DMat2), - ) - + UnaryOps - ( - Neg self -> self - ) - lua impl - { - - mut (MetaMethod::Index) => |ctx,s,idx : LuaIndex| { - Ok(LuaDVec2::new_ref( - s.script_ref(ctx.get_world()?).sub_ref(ReflectPathElem::SubReflectionIndexed{ - label:"col", - index: *idx, - get: |idx,ref_| Err(ReflectionError::InsufficientProvenance{ - path: "".to_owned(), - msg: "Cannot get column of matrix with immutable reference".to_owned() - }), - get_mut: |idx, ref_| { - if ref_.is::(){ - Ok(ref_.downcast_mut::() - .unwrap() - .col_mut(idx)) - } else { - Err(ReflectionError::CannotDowncast{from: ref_.type_name().to_owned().into(), to:"DMat2".into()}) - } - } - }) - ) - ) - } -; - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 3x3 column major matrix. - /// - ///This 3x3 matrix type features convenience methods for creating and using linear and - ///affine transformations. If you are primarily dealing with 2D affine transformations the - ///[`DAffine2`](crate::DAffine2) type is much faster and more space efficient than - ///using a 3x3 matrix. - /// - ///Linear transformations including 3D rotation and scale can be created using methods - ///such as [`Self::from_diagonal()`], [`Self::from_quat()`], [`Self::from_axis_angle()`], - ///[`Self::from_rotation_x()`], [`Self::from_rotation_y()`], or - ///[`Self::from_rotation_z()`]. - /// - ///The resulting matrices can be use to transform 3D vectors using regular vector - ///multiplication. - /// - ///Affine transformations including 2D translation, rotation and scale can be created - ///using methods such as [`Self::from_translation()`], [`Self::from_angle()`], - ///[`Self::from_scale()`] and [`Self::from_scale_angle_translation()`]. - /// - ///The [`Self::transform_point2()`] and [`Self::transform_vector2()`] convenience methods - ///are provided for performing affine transforms on 2D vectors and points. These multiply - ///2D inputs as 3D vectors with an implicit `z` value of `1` for points and `0` for - ///vectors respectively. These methods assume that `Self` contains a valid affine - ///transform. - glam::f64::DMat3 : - Clone + - Debug + - Methods - ( - ///Creates a 3x3 matrix from three column vectors. - from_cols(Wrapped(DVec3),Wrapped(DVec3),Wrapped(DVec3)) -> self, - - ///Creates a 3x3 matrix with its diagonal set to `diagonal` and all other entries set to 0. - from_diagonal(Wrapped(DVec3)) -> self, - - ///Creates a 3x3 matrix from a 4x4 matrix, discarding the 4th row and column. - from_mat4(Wrapped(DMat4)) -> self, - - ///Creates a 3D rotation matrix from the given quaternion. - /// - ///# Panics - /// - ///Will panic if `rotation` is not normalized when `glam_assert` is enabled. - from_quat(Wrapped(DQuat)) -> self, - - ///Creates a 3D rotation matrix from a normalized rotation `axis` and `angle` (in - ///radians). - /// - ///# Panics - /// - ///Will panic if `axis` is not normalized when `glam_assert` is enabled. - from_axis_angle(Wrapped(DVec3),Raw(f64)) -> self, - - ///Creates a 3D rotation matrix from the given euler rotation sequence and the angles (in - ///radians). - from_euler(Wrapped(EulerRot),Raw(f64),Raw(f64),Raw(f64)) -> self, - - ///Creates a 3D rotation matrix from `angle` (in radians) around the x axis. - from_rotation_x(Raw(f64)) -> self, - - ///Creates a 3D rotation matrix from `angle` (in radians) around the y axis. - from_rotation_y(Raw(f64)) -> self, - - ///Creates a 3D rotation matrix from `angle` (in radians) around the z axis. - from_rotation_z(Raw(f64)) -> self, - - ///Creates an affine transformation matrix from the given 2D `translation`. - /// - ///The resulting matrix can be used to transform 2D points and vectors. See - ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. - from_translation(Wrapped(DVec2)) -> self, - - ///Creates an affine transformation matrix from the given 2D rotation `angle` (in - ///radians). - /// - ///The resulting matrix can be used to transform 2D points and vectors. See - ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. - from_angle(Raw(f64)) -> self, - - ///Creates an affine transformation matrix from the given 2D `scale`, rotation `angle` (in - ///radians) and `translation`. - /// - ///The resulting matrix can be used to transform 2D points and vectors. See - ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. - from_scale_angle_translation(Wrapped(DVec2),Raw(f64),Wrapped(DVec2)) -> self, - - ///Creates an affine transformation matrix from the given non-uniform 2D `scale`. - /// - ///The resulting matrix can be used to transform 2D points and vectors. See - ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. - /// - ///# Panics - /// - ///Will panic if all elements of `scale` are zero when `glam_assert` is enabled. - from_scale(Wrapped(DVec2)) -> self, - - ///Creates an affine transformation matrix from the given 2x2 matrix. - /// - ///The resulting matrix can be used to transform 2D points and vectors. See - ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. - from_mat2(Wrapped(DMat2)) -> self, - - ///Returns the matrix column for the given `index`. - /// - ///# Panics - /// - ///Panics if `index` is greater than 2. - col(&self:Raw(usize)) -> Wrapped(DVec3), - - ///Returns the matrix row for the given `index`. - /// - ///# Panics - /// - ///Panics if `index` is greater than 2. - row(&self:Raw(usize)) -> Wrapped(DVec3), - - ///Returns `true` if, and only if, all elements are finite. - ///If any element is either `NaN`, positive or negative infinity, this will return `false`. - is_finite(&self:) -> Raw(bool), - - ///Returns `true` if any elements are `NaN`. - is_nan(&self:) -> Raw(bool), - - ///Returns the transpose of `self`. - transpose(&self:) -> self, - - ///Returns the determinant of `self`. - determinant(&self:) -> Raw(f64), - - ///Returns the inverse of `self`. - /// - ///If the matrix is not invertible the returned matrix will be invalid. - /// - ///# Panics - /// - ///Will panic if the determinant of `self` is zero when `glam_assert` is enabled. - inverse(&self:) -> self, - - ///Transforms the given 2D vector as a point. - /// - ///This is the equivalent of multiplying `rhs` as a 3D vector where `z` is `1`. - /// - ///This method assumes that `self` contains a valid affine transform. - /// - ///# Panics - /// - ///Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. - transform_point2(&self:Wrapped(DVec2)) -> Wrapped(DVec2), - - ///Rotates the given 2D vector. - /// - ///This is the equivalent of multiplying `rhs` as a 3D vector where `z` is `0`. - /// - ///This method assumes that `self` contains a valid affine transform. - /// - ///# Panics - /// - ///Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. - transform_vector2(&self:Wrapped(DVec2)) -> Wrapped(DVec2), - - ///Transforms a 3D vector. - mul_vec3(&self:Wrapped(DVec3)) -> Wrapped(DVec3), - - ///Multiplies two 3x3 matrices. - mul_mat3(&self:&self) -> self, - - ///Adds two 3x3 matrices. - add_mat3(&self:&self) -> self, - - ///Subtracts two 3x3 matrices. - sub_mat3(&self:&self) -> self, - - ///Multiplies a 3x3 matrix by a scalar. - mul_scalar(&self:Raw(f64)) -> self, - - ///Returns true if the absolute difference of all elements between `self` and `rhs` - ///is less than or equal to `max_abs_diff`. - /// - ///This can be used to compare if two matrices contain similar elements. It works best - ///when comparing with a known value. The `max_abs_diff` that should be used used - ///depends on the values being compared against. - /// - ///For more see - ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - abs_diff_eq(&self:self,Raw(f64)) -> Raw(bool), - - as_mat3(&self:) -> Wrapped(Mat3), - - ) - + Fields - ( - x_axis: Wrapped(DVec3), - y_axis: Wrapped(DVec3), - z_axis: Wrapped(DVec3), - ) - + BinOps - ( - self Add self -> Wrapped(DMat3), - self Sub self -> Wrapped(DMat3), - self Mul self -> Wrapped(DMat3), - self Mul Wrapped(DVec3) -> Wrapped(DVec3), - self Mul Wrapped(DMat3) -> Wrapped(DMat3), - self Mul Raw(f64) -> Wrapped(DMat3), - self Mul Wrapped(DAffine2) -> Wrapped(DMat3), - ) - + UnaryOps - ( - Neg self -> self - ) - lua impl - { - - mut (MetaMethod::Index) => |ctx,s,idx : LuaIndex| { - Ok(LuaDVec3::new_ref( - s.script_ref(ctx.get_world()?).sub_ref(ReflectPathElem::SubReflectionIndexed{ - label:"col", - index: *idx, - get: |idx,ref_| Err(ReflectionError::InsufficientProvenance{ - path: "".to_owned(), - msg: "Cannot get column of matrix with immutable reference".to_owned() - }), - get_mut: |idx, ref_| { - if ref_.is::(){ - Ok(ref_.downcast_mut::() - .unwrap() - .col_mut(idx)) - } else { - Err(ReflectionError::CannotDowncast{from: ref_.type_name().to_owned().into(), to:"DMat3".into()}) - } - } - }) - ) - ) - } -; - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 4x4 column major matrix. - /// - ///This 4x4 matrix type features convenience methods for creating and using affine transforms and - ///perspective projections. If you are primarily dealing with 3D affine transformations - ///considering using [`DAffine3`](crate::DAffine3) which is faster than a 4x4 matrix - ///for some affine operations. - /// - ///Affine transformations including 3D translation, rotation and scale can be created - ///using methods such as [`Self::from_translation()`], [`Self::from_quat()`], - ///[`Self::from_scale()`] and [`Self::from_scale_rotation_translation()`]. - /// - ///Orthographic projections can be created using the methods [`Self::orthographic_lh()`] for - ///left-handed coordinate systems and [`Self::orthographic_rh()`] for right-handed - ///systems. The resulting matrix is also an affine transformation. - /// - ///The [`Self::transform_point3()`] and [`Self::transform_vector3()`] convenience methods - ///are provided for performing affine transformations on 3D vectors and points. These - ///multiply 3D inputs as 4D vectors with an implicit `w` value of `1` for points and `0` - ///for vectors respectively. These methods assume that `Self` contains a valid affine - ///transform. - /// - ///Perspective projections can be created using methods such as - ///[`Self::perspective_lh()`], [`Self::perspective_infinite_lh()`] and - ///[`Self::perspective_infinite_reverse_lh()`] for left-handed co-ordinate systems and - ///[`Self::perspective_rh()`], [`Self::perspective_infinite_rh()`] and - ///[`Self::perspective_infinite_reverse_rh()`] for right-handed co-ordinate systems. - /// - ///The resulting perspective project can be use to transform 3D vectors as points with - ///perspective correction using the [`Self::project_point3()`] convenience method. - glam::f64::DMat4 : - Clone + - Debug + - Methods - ( - ///Creates a 4x4 matrix from four column vectors. - from_cols(Wrapped(DVec4),Wrapped(DVec4),Wrapped(DVec4),Wrapped(DVec4)) -> self, - - ///Creates a 4x4 matrix with its diagonal set to `diagonal` and all other entries set to 0. - from_diagonal(Wrapped(DVec4)) -> self, - - ///Creates an affine transformation matrix from the given 3D `scale`, `rotation` and - ///`translation`. - /// - ///The resulting matrix can be used to transform 3D points and vectors. See - ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. - /// - ///# Panics - /// - ///Will panic if `rotation` is not normalized when `glam_assert` is enabled. - from_scale_rotation_translation(Wrapped(DVec3),Wrapped(DQuat),Wrapped(DVec3)) -> self, - - ///Creates an affine transformation matrix from the given 3D `translation`. - /// - ///The resulting matrix can be used to transform 3D points and vectors. See - ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. - /// - ///# Panics - /// - ///Will panic if `rotation` is not normalized when `glam_assert` is enabled. - from_rotation_translation(Wrapped(DQuat),Wrapped(DVec3)) -> self, - - ///Creates an affine transformation matrix from the given `rotation` quaternion. - /// - ///The resulting matrix can be used to transform 3D points and vectors. See - ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. - /// - ///# Panics - /// - ///Will panic if `rotation` is not normalized when `glam_assert` is enabled. - from_quat(Wrapped(DQuat)) -> self, - - ///Creates an affine transformation matrix from the given 3x3 linear transformation - ///matrix. - /// - ///The resulting matrix can be used to transform 3D points and vectors. See - ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. - from_mat3(Wrapped(DMat3)) -> self, - - ///Creates an affine transformation matrix from the given 3D `translation`. - /// - ///The resulting matrix can be used to transform 3D points and vectors. See - ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. - from_translation(Wrapped(DVec3)) -> self, - - ///Creates an affine transformation matrix containing a 3D rotation around a normalized - ///rotation `axis` of `angle` (in radians). - /// - ///The resulting matrix can be used to transform 3D points and vectors. See - ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. - /// - ///# Panics - /// - ///Will panic if `axis` is not normalized when `glam_assert` is enabled. - from_axis_angle(Wrapped(DVec3),Raw(f64)) -> self, - - ///Creates a affine transformation matrix containing a rotation from the given euler - ///rotation sequence and angles (in radians). - /// - ///The resulting matrix can be used to transform 3D points and vectors. See - ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. - from_euler(Wrapped(EulerRot),Raw(f64),Raw(f64),Raw(f64)) -> self, - - ///Creates an affine transformation matrix containing a 3D rotation around the x axis of - ///`angle` (in radians). - /// - ///The resulting matrix can be used to transform 3D points and vectors. See - ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. - from_rotation_x(Raw(f64)) -> self, - - ///Creates an affine transformation matrix containing a 3D rotation around the y axis of - ///`angle` (in radians). - /// - ///The resulting matrix can be used to transform 3D points and vectors. See - ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. - from_rotation_y(Raw(f64)) -> self, - - ///Creates an affine transformation matrix containing a 3D rotation around the z axis of - ///`angle` (in radians). - /// - ///The resulting matrix can be used to transform 3D points and vectors. See - ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. - from_rotation_z(Raw(f64)) -> self, - - ///Creates an affine transformation matrix containing the given 3D non-uniform `scale`. - /// - ///The resulting matrix can be used to transform 3D points and vectors. See - ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. - /// - ///# Panics - /// - ///Will panic if all elements of `scale` are zero when `glam_assert` is enabled. - from_scale(Wrapped(DVec3)) -> self, - - ///Returns the matrix column for the given `index`. - /// - ///# Panics - /// - ///Panics if `index` is greater than 3. - col(&self:Raw(usize)) -> Wrapped(DVec4), - - ///Returns the matrix row for the given `index`. - /// - ///# Panics - /// - ///Panics if `index` is greater than 3. - row(&self:Raw(usize)) -> Wrapped(DVec4), - - ///Returns `true` if, and only if, all elements are finite. - ///If any element is either `NaN`, positive or negative infinity, this will return `false`. - is_finite(&self:) -> Raw(bool), - - ///Returns `true` if any elements are `NaN`. - is_nan(&self:) -> Raw(bool), - - ///Returns the transpose of `self`. - transpose(&self:) -> self, - - ///Returns the determinant of `self`. - determinant(&self:) -> Raw(f64), - - ///Returns the inverse of `self`. - /// - ///If the matrix is not invertible the returned matrix will be invalid. - /// - ///# Panics - /// - ///Will panic if the determinant of `self` is zero when `glam_assert` is enabled. - inverse(&self:) -> self, - - ///Creates a left-handed view matrix using a camera position, an up direction, and a facing - ///direction. - /// - ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. - look_to_lh(Wrapped(DVec3),Wrapped(DVec3),Wrapped(DVec3)) -> self, - - ///Creates a right-handed view matrix using a camera position, an up direction, and a facing - ///direction. - /// - ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. - look_to_rh(Wrapped(DVec3),Wrapped(DVec3),Wrapped(DVec3)) -> self, - - ///Creates a left-handed view matrix using a camera position, an up direction, and a focal - ///point. - ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. - /// - ///# Panics - /// - ///Will panic if `up` is not normalized when `glam_assert` is enabled. - look_at_lh(Wrapped(DVec3),Wrapped(DVec3),Wrapped(DVec3)) -> self, - - ///Creates a right-handed view matrix using a camera position, an up direction, and a focal - ///point. - ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. - /// - ///# Panics - /// - ///Will panic if `up` is not normalized when `glam_assert` is enabled. - look_at_rh(Wrapped(DVec3),Wrapped(DVec3),Wrapped(DVec3)) -> self, - - ///Creates a right-handed perspective projection matrix with [-1,1] depth range. - ///This is the same as the OpenGL `gluPerspective` function. - ///See - perspective_rh_gl(Raw(f64),Raw(f64),Raw(f64),Raw(f64)) -> self, - - ///Creates a left-handed perspective projection matrix with `[0,1]` depth range. - /// - ///# Panics - /// - ///Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is - ///enabled. - perspective_lh(Raw(f64),Raw(f64),Raw(f64),Raw(f64)) -> self, - - ///Creates a right-handed perspective projection matrix with `[0,1]` depth range. - /// - ///# Panics - /// - ///Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is - ///enabled. - perspective_rh(Raw(f64),Raw(f64),Raw(f64),Raw(f64)) -> self, - - ///Creates an infinite left-handed perspective projection matrix with `[0,1]` depth range. - /// - ///# Panics - /// - ///Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. - perspective_infinite_lh(Raw(f64),Raw(f64),Raw(f64)) -> self, - - ///Creates an infinite left-handed perspective projection matrix with `[0,1]` depth range. - /// - ///# Panics - /// - ///Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. - perspective_infinite_reverse_lh(Raw(f64),Raw(f64),Raw(f64)) -> self, - - ///Creates an infinite right-handed perspective projection matrix with - ///`[0,1]` depth range. - perspective_infinite_rh(Raw(f64),Raw(f64),Raw(f64)) -> self, - - ///Creates an infinite reverse right-handed perspective projection matrix - ///with `[0,1]` depth range. - perspective_infinite_reverse_rh(Raw(f64),Raw(f64),Raw(f64)) -> self, - - ///Creates a right-handed orthographic projection matrix with `[-1,1]` depth - ///range. This is the same as the OpenGL `glOrtho` function in OpenGL. - ///See - /// - orthographic_rh_gl(Raw(f64),Raw(f64),Raw(f64),Raw(f64),Raw(f64),Raw(f64)) -> self, - - ///Creates a left-handed orthographic projection matrix with `[0,1]` depth range. - orthographic_lh(Raw(f64),Raw(f64),Raw(f64),Raw(f64),Raw(f64),Raw(f64)) -> self, - - ///Creates a right-handed orthographic projection matrix with `[0,1]` depth range. - orthographic_rh(Raw(f64),Raw(f64),Raw(f64),Raw(f64),Raw(f64),Raw(f64)) -> self, - - ///Transforms the given 3D vector as a point, applying perspective correction. - /// - ///This is the equivalent of multiplying the 3D vector as a 4D vector where `w` is `1.0`. - ///The perspective divide is performed meaning the resulting 3D vector is divided by `w`. - /// - ///This method assumes that `self` contains a projective transform. - project_point3(&self:Wrapped(DVec3)) -> Wrapped(DVec3), - - ///Transforms the given 3D vector as a point. - /// - ///This is the equivalent of multiplying the 3D vector as a 4D vector where `w` is - ///`1.0`. - /// - ///This method assumes that `self` contains a valid affine transform. It does not perform - ///a persective divide, if `self` contains a perspective transform, or if you are unsure, - ///the [`Self::project_point3()`] method should be used instead. - /// - ///# Panics - /// - ///Will panic if the 3rd row of `self` is not `(0, 0, 0, 1)` when `glam_assert` is enabled. - transform_point3(&self:Wrapped(DVec3)) -> Wrapped(DVec3), - - ///Transforms the give 3D vector as a direction. - /// - ///This is the equivalent of multiplying the 3D vector as a 4D vector where `w` is - ///`0.0`. - /// - ///This method assumes that `self` contains a valid affine transform. - /// - ///# Panics - /// - ///Will panic if the 3rd row of `self` is not `(0, 0, 0, 1)` when `glam_assert` is enabled. - transform_vector3(&self:Wrapped(DVec3)) -> Wrapped(DVec3), - - ///Transforms a 4D vector. - mul_vec4(&self:Wrapped(DVec4)) -> Wrapped(DVec4), - - ///Multiplies two 4x4 matrices. - mul_mat4(&self:&self) -> self, - - ///Adds two 4x4 matrices. - add_mat4(&self:&self) -> self, - - ///Subtracts two 4x4 matrices. - sub_mat4(&self:&self) -> self, - - ///Multiplies a 4x4 matrix by a scalar. - mul_scalar(&self:Raw(f64)) -> self, - - ///Returns true if the absolute difference of all elements between `self` and `rhs` - ///is less than or equal to `max_abs_diff`. - /// - ///This can be used to compare if two matrices contain similar elements. It works best - ///when comparing with a known value. The `max_abs_diff` that should be used used - ///depends on the values being compared against. - /// - ///For more see - ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - abs_diff_eq(&self:self,Raw(f64)) -> Raw(bool), - - as_mat4(&self:) -> Wrapped(Mat4), - - ) - + Fields - ( - x_axis: Wrapped(DVec4), - y_axis: Wrapped(DVec4), - z_axis: Wrapped(DVec4), - w_axis: Wrapped(DVec4), - ) - + BinOps - ( - self Add self -> Wrapped(DMat4), - self Sub self -> Wrapped(DMat4), - self Mul Wrapped(DAffine3) -> Wrapped(DMat4), - self Mul Raw(f64) -> Wrapped(DMat4), - self Mul self -> Wrapped(DMat4), - self Mul Wrapped(DMat4) -> Wrapped(DMat4), - self Mul Wrapped(DVec4) -> Wrapped(DVec4), - ) - + UnaryOps - ( - Neg self -> self - ) - lua impl - { - - mut (MetaMethod::Index) => |ctx,s,idx : LuaIndex| { - Ok(LuaDVec4::new_ref( - s.script_ref(ctx.get_world()?).sub_ref(ReflectPathElem::SubReflectionIndexed{ - label:"col", - index: *idx, - get: |idx,ref_| Err(ReflectionError::InsufficientProvenance{ - path: "".to_owned(), - msg: "Cannot get column of matrix with immutable reference".to_owned() - }), - get_mut: |idx, ref_| { - if ref_.is::(){ - Ok(ref_.downcast_mut::() - .unwrap() - .col_mut(idx)) - } else { - Err(ReflectionError::CannotDowncast{from: ref_.type_name().to_owned().into(), to:"DMat4".into()}) - } - } - }) - ) - ) - } -; - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 2D affine transform, which can represent translation, rotation, scaling and shear. - glam::f32::Affine2 : - Clone + - Debug + - Methods - ( - ///Creates an affine transform from three column vectors. - from_cols(Wrapped(Vec2),Wrapped(Vec2),Wrapped(Vec2)) -> self, - - ///Creates an affine transform that changes scale. - ///Note that if any scale is zero the transform will be non-invertible. - from_scale(Wrapped(Vec2)) -> self, - - ///Creates an affine transform from the given rotation `angle`. - from_angle(Raw(f32)) -> self, - - ///Creates an affine transformation from the given 2D `translation`. - from_translation(Wrapped(Vec2)) -> self, - - ///Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) - from_mat2(Wrapped(Mat2)) -> self, - - ///Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) and a - ///translation vector. - /// - ///Equivalent to - ///`Affine2::from_translation(translation) * Affine2::from_mat2(mat2)` - from_mat2_translation(Wrapped(Mat2),Wrapped(Vec2)) -> self, - - ///Creates an affine transform from the given 2D `scale`, rotation `angle` (in radians) and - ///`translation`. - /// - ///Equivalent to `Affine2::from_translation(translation) * - ///Affine2::from_angle(angle) * Affine2::from_scale(scale)` - from_scale_angle_translation(Wrapped(Vec2),Raw(f32),Wrapped(Vec2)) -> self, - - ///Creates an affine transform from the given 2D rotation `angle` (in radians) and - ///`translation`. - /// - ///Equivalent to `Affine2::from_translation(translation) * Affine2::from_angle(angle)` - from_angle_translation(Raw(f32),Wrapped(Vec2)) -> self, - - ///The given `Mat3` must be an affine transform, - from_mat3(Wrapped(Mat3)) -> self, - - ///The given [`Mat3A`] must be an affine transform, - from_mat3a(Wrapped(Mat3A)) -> self, - - ///Transforms the given 2D point, applying shear, scale, rotation and translation. - transform_point2(&self:Wrapped(Vec2)) -> Wrapped(Vec2), - - ///Transforms the given 2D vector, applying shear, scale and rotation (but NOT - ///translation). - /// - ///To also apply translation, use [`Self::transform_point2()`] instead. - transform_vector2(&self:Wrapped(Vec2)) -> Wrapped(Vec2), - - ///Returns `true` if, and only if, all elements are finite. - /// - ///If any element is either `NaN`, positive or negative infinity, this will return - ///`false`. - is_finite(&self:) -> Raw(bool), - - ///Returns `true` if any elements are `NaN`. - is_nan(&self:) -> Raw(bool), - - ///Returns true if the absolute difference of all elements between `self` and `rhs` - ///is less than or equal to `max_abs_diff`. - /// - ///This can be used to compare if two 3x4 matrices contain similar elements. It works - ///best when comparing with a known value. The `max_abs_diff` that should be used used - ///depends on the values being compared against. - /// - ///For more see - ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - abs_diff_eq(&self:self,Raw(f32)) -> Raw(bool), - - ///Return the inverse of this transform. - /// - ///Note that if the transform is not invertible the result will be invalid. - inverse(&self:) -> self, - - ) - + Fields - ( - matrix2: Wrapped(Mat2), - translation: Wrapped(Vec2), - ) - + BinOps - ( - self Mul Wrapped(Mat3A) -> Wrapped(Mat3A), - self Mul Wrapped(Mat3) -> Wrapped(Mat3), - self Mul Wrapped(Affine2) -> Wrapped(Affine2), - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 3D affine transform, which can represent translation, rotation, scaling and shear. - /// - ///This type is 16 byte aligned. - glam::f32::Affine3A : - Clone + - Debug + - Methods - ( - ///Creates an affine transform from three column vectors. - from_cols(Wrapped(Vec3A),Wrapped(Vec3A),Wrapped(Vec3A),Wrapped(Vec3A)) -> self, - - ///Creates an affine transform that changes scale. - ///Note that if any scale is zero the transform will be non-invertible. - from_scale(Wrapped(Vec3)) -> self, - - ///Creates an affine transform from the given `rotation` quaternion. - from_quat(Wrapped(Quat)) -> self, - - ///Creates an affine transform containing a 3D rotation around a normalized - ///rotation `axis` of `angle` (in radians). - from_axis_angle(Wrapped(Vec3),Raw(f32)) -> self, - - ///Creates an affine transform containing a 3D rotation around the x axis of - ///`angle` (in radians). - from_rotation_x(Raw(f32)) -> self, - - ///Creates an affine transform containing a 3D rotation around the y axis of - ///`angle` (in radians). - from_rotation_y(Raw(f32)) -> self, - - ///Creates an affine transform containing a 3D rotation around the z axis of - ///`angle` (in radians). - from_rotation_z(Raw(f32)) -> self, - - ///Creates an affine transformation from the given 3D `translation`. - from_translation(Wrapped(Vec3)) -> self, - - ///Creates an affine transform from a 3x3 matrix (expressing scale, shear and - ///rotation) - from_mat3(Wrapped(Mat3)) -> self, - - ///Creates an affine transform from a 3x3 matrix (expressing scale, shear and rotation) - ///and a translation vector. - /// - ///Equivalent to `Affine3A::from_translation(translation) * Affine3A::from_mat3(mat3)` - from_mat3_translation(Wrapped(Mat3),Wrapped(Vec3)) -> self, - - ///Creates an affine transform from the given 3D `scale`, `rotation` and - ///`translation`. - /// - ///Equivalent to `Affine3A::from_translation(translation) * - ///Affine3A::from_quat(rotation) * Affine3A::from_scale(scale)` - from_scale_rotation_translation(Wrapped(Vec3),Wrapped(Quat),Wrapped(Vec3)) -> self, - - ///Creates an affine transform from the given 3D `rotation` and `translation`. - /// - ///Equivalent to `Affine3A::from_translation(translation) * Affine3A::from_quat(rotation)` - from_rotation_translation(Wrapped(Quat),Wrapped(Vec3)) -> self, - - ///The given `Mat4` must be an affine transform, - ///i.e. contain no perspective transform. - from_mat4(Wrapped(Mat4)) -> self, - - ///Creates a left-handed view transform using a camera position, an up direction, and a facing - ///direction. - /// - ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. - look_to_lh(Wrapped(Vec3),Wrapped(Vec3),Wrapped(Vec3)) -> self, - - ///Creates a right-handed view transform using a camera position, an up direction, and a facing - ///direction. - /// - ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. - look_to_rh(Wrapped(Vec3),Wrapped(Vec3),Wrapped(Vec3)) -> self, - - ///Creates a left-handed view transform using a camera position, an up direction, and a focal - ///point. - ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. - /// - ///# Panics - /// - ///Will panic if `up` is not normalized when `glam_assert` is enabled. - look_at_lh(Wrapped(Vec3),Wrapped(Vec3),Wrapped(Vec3)) -> self, - - ///Creates a right-handed view transform using a camera position, an up direction, and a focal - ///point. - ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. - /// - ///# Panics - /// - ///Will panic if `up` is not normalized when `glam_assert` is enabled. - look_at_rh(Wrapped(Vec3),Wrapped(Vec3),Wrapped(Vec3)) -> self, - - ///Transforms the given 3D points, applying shear, scale, rotation and translation. - transform_point3(&self:Wrapped(Vec3)) -> Wrapped(Vec3), - - ///Transforms the given 3D vector, applying shear, scale and rotation (but NOT - ///translation). - /// - ///To also apply translation, use [`Self::transform_point3()`] instead. - transform_vector3(&self:Wrapped(Vec3)) -> Wrapped(Vec3), - - ///Transforms the given [`Vec3A`], applying shear, scale, rotation and translation. - transform_point3a(&self:Wrapped(Vec3A)) -> Wrapped(Vec3A), - - ///Transforms the given [`Vec3A`], applying shear, scale and rotation (but NOT - ///translation). - /// - ///To also apply translation, use [`Self::transform_point3a()`] instead. - transform_vector3a(&self:Wrapped(Vec3A)) -> Wrapped(Vec3A), - - ///Returns `true` if, and only if, all elements are finite. - /// - ///If any element is either `NaN`, positive or negative infinity, this will return - ///`false`. - is_finite(&self:) -> Raw(bool), - - ///Returns `true` if any elements are `NaN`. - is_nan(&self:) -> Raw(bool), - - ///Returns true if the absolute difference of all elements between `self` and `rhs` - ///is less than or equal to `max_abs_diff`. - /// - ///This can be used to compare if two 3x4 matrices contain similar elements. It works - ///best when comparing with a known value. The `max_abs_diff` that should be used used - ///depends on the values being compared against. - /// - ///For more see - ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - abs_diff_eq(&self:self,Raw(f32)) -> Raw(bool), - - ///Return the inverse of this transform. - /// - ///Note that if the transform is not invertible the result will be invalid. - inverse(&self:) -> self, - - ) - + Fields - ( - matrix3: Wrapped(Mat3A), - translation: Wrapped(Vec3A), - ) - + BinOps - ( - self Mul Wrapped(Mat4) -> Wrapped(Mat4), - self Mul Wrapped(Affine3A) -> Wrapped(Affine3A), - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 2D affine transform, which can represent translation, rotation, scaling and shear. - glam::f64::DAffine2 : - Clone + - Debug + - Methods - ( - ///Creates an affine transform from three column vectors. - from_cols(Wrapped(DVec2),Wrapped(DVec2),Wrapped(DVec2)) -> self, - - ///Creates an affine transform that changes scale. - ///Note that if any scale is zero the transform will be non-invertible. - from_scale(Wrapped(DVec2)) -> self, - - ///Creates an affine transform from the given rotation `angle`. - from_angle(Raw(f64)) -> self, - - ///Creates an affine transformation from the given 2D `translation`. - from_translation(Wrapped(DVec2)) -> self, - - ///Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) - from_mat2(Wrapped(DMat2)) -> self, - - ///Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) and a - ///translation vector. - /// - ///Equivalent to - ///`DAffine2::from_translation(translation) * DAffine2::from_mat2(mat2)` - from_mat2_translation(Wrapped(DMat2),Wrapped(DVec2)) -> self, - - ///Creates an affine transform from the given 2D `scale`, rotation `angle` (in radians) and - ///`translation`. - /// - ///Equivalent to `DAffine2::from_translation(translation) * - ///DAffine2::from_angle(angle) * DAffine2::from_scale(scale)` - from_scale_angle_translation(Wrapped(DVec2),Raw(f64),Wrapped(DVec2)) -> self, - - ///Creates an affine transform from the given 2D rotation `angle` (in radians) and - ///`translation`. - /// - ///Equivalent to `DAffine2::from_translation(translation) * DAffine2::from_angle(angle)` - from_angle_translation(Raw(f64),Wrapped(DVec2)) -> self, - - ///The given `DMat3` must be an affine transform, - from_mat3(Wrapped(DMat3)) -> self, - - ///Transforms the given 2D point, applying shear, scale, rotation and translation. - transform_point2(&self:Wrapped(DVec2)) -> Wrapped(DVec2), - - ///Transforms the given 2D vector, applying shear, scale and rotation (but NOT - ///translation). - /// - ///To also apply translation, use [`Self::transform_point2()`] instead. - transform_vector2(&self:Wrapped(DVec2)) -> Wrapped(DVec2), - - ///Returns `true` if, and only if, all elements are finite. - /// - ///If any element is either `NaN`, positive or negative infinity, this will return - ///`false`. - is_finite(&self:) -> Raw(bool), - - ///Returns `true` if any elements are `NaN`. - is_nan(&self:) -> Raw(bool), - - ///Returns true if the absolute difference of all elements between `self` and `rhs` - ///is less than or equal to `max_abs_diff`. - /// - ///This can be used to compare if two 3x4 matrices contain similar elements. It works - ///best when comparing with a known value. The `max_abs_diff` that should be used used - ///depends on the values being compared against. - /// - ///For more see - ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - abs_diff_eq(&self:self,Raw(f64)) -> Raw(bool), - - ///Return the inverse of this transform. - /// - ///Note that if the transform is not invertible the result will be invalid. - inverse(&self:) -> self, - - ) - + Fields - ( - matrix2: Wrapped(DMat2), - translation: Wrapped(DVec2), - ) - + BinOps - ( - self Mul Wrapped(DMat3) -> Wrapped(DMat3), - self Mul Wrapped(DAffine2) -> Wrapped(DAffine2), - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A 3D affine transform, which can represent translation, rotation, scaling and shear. - glam::f64::DAffine3 : - Clone + - Debug + - Methods - ( - ///Creates an affine transform from three column vectors. - from_cols(Wrapped(DVec3),Wrapped(DVec3),Wrapped(DVec3),Wrapped(DVec3)) -> self, - - ///Creates an affine transform that changes scale. - ///Note that if any scale is zero the transform will be non-invertible. - from_scale(Wrapped(DVec3)) -> self, - - ///Creates an affine transform from the given `rotation` quaternion. - from_quat(Wrapped(DQuat)) -> self, - - ///Creates an affine transform containing a 3D rotation around a normalized - ///rotation `axis` of `angle` (in radians). - from_axis_angle(Wrapped(DVec3),Raw(f64)) -> self, - - ///Creates an affine transform containing a 3D rotation around the x axis of - ///`angle` (in radians). - from_rotation_x(Raw(f64)) -> self, - - ///Creates an affine transform containing a 3D rotation around the y axis of - ///`angle` (in radians). - from_rotation_y(Raw(f64)) -> self, - - ///Creates an affine transform containing a 3D rotation around the z axis of - ///`angle` (in radians). - from_rotation_z(Raw(f64)) -> self, - - ///Creates an affine transformation from the given 3D `translation`. - from_translation(Wrapped(DVec3)) -> self, - - ///Creates an affine transform from a 3x3 matrix (expressing scale, shear and - ///rotation) - from_mat3(Wrapped(DMat3)) -> self, - - ///Creates an affine transform from a 3x3 matrix (expressing scale, shear and rotation) - ///and a translation vector. - /// - ///Equivalent to `DAffine3::from_translation(translation) * DAffine3::from_mat3(mat3)` - from_mat3_translation(Wrapped(DMat3),Wrapped(DVec3)) -> self, - - ///Creates an affine transform from the given 3D `scale`, `rotation` and - ///`translation`. - /// - ///Equivalent to `DAffine3::from_translation(translation) * - ///DAffine3::from_quat(rotation) * DAffine3::from_scale(scale)` - from_scale_rotation_translation(Wrapped(DVec3),Wrapped(DQuat),Wrapped(DVec3)) -> self, - - ///Creates an affine transform from the given 3D `rotation` and `translation`. - /// - ///Equivalent to `DAffine3::from_translation(translation) * DAffine3::from_quat(rotation)` - from_rotation_translation(Wrapped(DQuat),Wrapped(DVec3)) -> self, - - ///The given `DMat4` must be an affine transform, - ///i.e. contain no perspective transform. - from_mat4(Wrapped(DMat4)) -> self, - - ///Creates a left-handed view transform using a camera position, an up direction, and a facing - ///direction. - /// - ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. - look_to_lh(Wrapped(DVec3),Wrapped(DVec3),Wrapped(DVec3)) -> self, - - ///Creates a right-handed view transform using a camera position, an up direction, and a facing - ///direction. - /// - ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. - look_to_rh(Wrapped(DVec3),Wrapped(DVec3),Wrapped(DVec3)) -> self, - - ///Creates a left-handed view transform using a camera position, an up direction, and a focal - ///point. - ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. - /// - ///# Panics - /// - ///Will panic if `up` is not normalized when `glam_assert` is enabled. - look_at_lh(Wrapped(DVec3),Wrapped(DVec3),Wrapped(DVec3)) -> self, - - ///Creates a right-handed view transform using a camera position, an up direction, and a focal - ///point. - ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. - /// - ///# Panics - /// - ///Will panic if `up` is not normalized when `glam_assert` is enabled. - look_at_rh(Wrapped(DVec3),Wrapped(DVec3),Wrapped(DVec3)) -> self, - - ///Transforms the given 3D points, applying shear, scale, rotation and translation. - transform_point3(&self:Wrapped(DVec3)) -> Wrapped(DVec3), - - ///Transforms the given 3D vector, applying shear, scale and rotation (but NOT - ///translation). - /// - ///To also apply translation, use [`Self::transform_point3()`] instead. - transform_vector3(&self:Wrapped(DVec3)) -> Wrapped(DVec3), - - ///Returns `true` if, and only if, all elements are finite. - /// - ///If any element is either `NaN`, positive or negative infinity, this will return - ///`false`. - is_finite(&self:) -> Raw(bool), - - ///Returns `true` if any elements are `NaN`. - is_nan(&self:) -> Raw(bool), - - ///Returns true if the absolute difference of all elements between `self` and `rhs` - ///is less than or equal to `max_abs_diff`. - /// - ///This can be used to compare if two 3x4 matrices contain similar elements. It works - ///best when comparing with a known value. The `max_abs_diff` that should be used used - ///depends on the values being compared against. - /// - ///For more see - ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - abs_diff_eq(&self:self,Raw(f64)) -> Raw(bool), - - ///Return the inverse of this transform. - /// - ///Note that if the transform is not invertible the result will be invalid. - inverse(&self:) -> self, - - ) - + Fields - ( - matrix3: Wrapped(DMat3), - translation: Wrapped(DVec3), - ) - + BinOps - ( - self Mul Wrapped(DMat4) -> Wrapped(DMat4), - self Mul Wrapped(DAffine3) -> Wrapped(DAffine3), - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A quaternion representing an orientation. - /// - ///This quaternion is intended to be of unit length but may denormalize due to - ///floating point "error creep" which can occur when successive quaternion - ///operations are applied. - /// - ///SIMD vector types are used for storage on supported platforms. - /// - ///This type is 16 byte aligned. - glam::f32::Quat : - Clone + - Debug + - Methods - ( - ///Creates a new rotation quaternion. - /// - ///This should generally not be called manually unless you know what you are doing. - ///Use one of the other constructors instead such as `identity` or `from_axis_angle`. - /// - ///`from_xyzw` is mostly used by unit tests and `serde` deserialization. - /// - ///# Preconditions - /// - ///This function does not check if the input is normalized, it is up to the user to - ///provide normalized input or to normalized the resulting quaternion. - from_xyzw(Raw(f32),Raw(f32),Raw(f32),Raw(f32)) -> self, - - ///Creates a new rotation quaternion from a 4D vector. - /// - ///# Preconditions - /// - ///This function does not check if the input is normalized, it is up to the user to - ///provide normalized input or to normalized the resulting quaternion. - from_vec4(Wrapped(Vec4)) -> self, - - ///Create a quaternion for a normalized rotation `axis` and `angle` (in radians). - /// - ///The axis must be a unit vector. - /// - ///# Panics - /// - ///Will panic if `axis` is not normalized when `glam_assert` is enabled. - from_axis_angle(Wrapped(Vec3),Raw(f32)) -> self, - - ///Create a quaternion that rotates `v.length()` radians around `v.normalize()`. - /// - ///`from_scaled_axis(Vec3::ZERO)` results in the identity quaternion. - from_scaled_axis(Wrapped(Vec3)) -> self, - - ///Creates a quaternion from the `angle` (in radians) around the x axis. - from_rotation_x(Raw(f32)) -> self, - - ///Creates a quaternion from the `angle` (in radians) around the y axis. - from_rotation_y(Raw(f32)) -> self, - - ///Creates a quaternion from the `angle` (in radians) around the z axis. - from_rotation_z(Raw(f32)) -> self, - - ///Creates a quaternion from the given Euler rotation sequence and the angles (in radians). - from_euler(Wrapped(EulerRot),Raw(f32),Raw(f32),Raw(f32)) -> self, - - ///Creates a quaternion from a 3x3 rotation matrix. - from_mat3(Wrapped(&Mat3)) -> self, - - ///Creates a quaternion from a 3x3 SIMD aligned rotation matrix. - from_mat3a(Wrapped(&Mat3A)) -> self, - - ///Creates a quaternion from a 3x3 rotation matrix inside a homogeneous 4x4 matrix. - from_mat4(Wrapped(&Mat4)) -> self, - - ///Gets the minimal rotation for transforming `from` to `to`. The rotation is in the - ///plane spanned by the two vectors. Will rotate at most 180 degrees. - /// - ///The inputs must be unit vectors. - /// - ///`from_rotation_arc(from, to) * from ≈ to`. - /// - ///For near-singular cases (from≈to and from≈-to) the current implementation - ///is only accurate to about 0.001 (for `f32`). - /// - ///# Panics - /// - ///Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. - from_rotation_arc(Wrapped(Vec3),Wrapped(Vec3)) -> self, - - ///Gets the minimal rotation for transforming `from` to either `to` or `-to`. This means - ///that the resulting quaternion will rotate `from` so that it is colinear with `to`. - /// - ///The rotation is in the plane spanned by the two vectors. Will rotate at most 90 - ///degrees. - /// - ///The inputs must be unit vectors. - /// - ///`to.dot(from_rotation_arc_colinear(from, to) * from).abs() ≈ 1`. - /// - ///# Panics - /// - ///Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. - from_rotation_arc_colinear(Wrapped(Vec3),Wrapped(Vec3)) -> self, - - ///Gets the minimal rotation for transforming `from` to `to`. The resulting rotation is - ///around the z axis. Will rotate at most 180 degrees. - /// - ///The inputs must be unit vectors. - /// - ///`from_rotation_arc_2d(from, to) * from ≈ to`. - /// - ///For near-singular cases (from≈to and from≈-to) the current implementation - ///is only accurate to about 0.001 (for `f32`). - /// - ///# Panics - /// - ///Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. - from_rotation_arc_2d(Wrapped(Vec2),Wrapped(Vec2)) -> self, - - ///Returns the rotation axis scaled by the rotation in radians. - to_scaled_axis(self:) -> Wrapped(Vec3), - - ///Returns the vector part of the quaternion. - xyz(self:) -> Wrapped(Vec3), - - ///Returns the quaternion conjugate of `self`. For a unit quaternion the - ///conjugate is also the inverse. - conjugate(self:) -> self, - - ///Returns the inverse of a normalized quaternion. - /// - ///Typically quaternion inverse returns the conjugate of a normalized quaternion. - ///Because `self` is assumed to already be unit length this method *does not* normalize - ///before returning the conjugate. - /// - ///# Panics - /// - ///Will panic if `self` is not normalized when `glam_assert` is enabled. - inverse(self:) -> self, - - ///Computes the dot product of `self` and `rhs`. The dot product is - ///equal to the cosine of the angle between two quaternion rotations. - dot(self:self) -> Raw(f32), - - ///Computes the length of `self`. - length(self:) -> Raw(f32), - - ///Computes the squared length of `self`. - /// - ///This is generally faster than `length()` as it avoids a square - ///root operation. - length_squared(self:) -> Raw(f32), - - ///Computes `1.0 / length()`. - /// - ///For valid results, `self` must _not_ be of length zero. - length_recip(self:) -> Raw(f32), - - ///Returns `self` normalized to length 1.0. - /// - ///For valid results, `self` must _not_ be of length zero. - /// - ///Panics - /// - ///Will panic if `self` is zero length when `glam_assert` is enabled. - normalize(self:) -> self, - - ///Returns `true` if, and only if, all elements are finite. - ///If any element is either `NaN`, positive or negative infinity, this will return `false`. - is_finite(self:) -> Raw(bool), - - is_nan(self:) -> Raw(bool), - - ///Returns whether `self` of length `1.0` or not. - /// - ///Uses a precision threshold of `1e-6`. - is_normalized(self:) -> Raw(bool), - - is_near_identity(self:) -> Raw(bool), - - ///Returns the angle (in radians) for the minimal rotation - ///for transforming this quaternion into another. - /// - ///Both quaternions must be normalized. - /// - ///# Panics - /// - ///Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. - angle_between(self:self) -> Raw(f32), - - ///Returns true if the absolute difference of all elements between `self` and `rhs` - ///is less than or equal to `max_abs_diff`. - /// - ///This can be used to compare if two quaternions contain similar elements. It works - ///best when comparing with a known value. The `max_abs_diff` that should be used used - ///depends on the values being compared against. - /// - ///For more see - ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - abs_diff_eq(self:self,Raw(f32)) -> Raw(bool), - - ///Performs a linear interpolation between `self` and `rhs` based on - ///the value `s`. - /// - ///When `s` is `0.0`, the result will be equal to `self`. When `s` - ///is `1.0`, the result will be equal to `rhs`. - /// - ///# Panics - /// - ///Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. - lerp(self:self,Raw(f32)) -> self, - - ///Performs a spherical linear interpolation between `self` and `end` - ///based on the value `s`. - /// - ///When `s` is `0.0`, the result will be equal to `self`. When `s` - ///is `1.0`, the result will be equal to `end`. - /// - ///# Panics - /// - ///Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. - slerp(self:self,Raw(f32)) -> self, - - ///Multiplies a quaternion and a 3D vector, returning the rotated vector. - /// - ///# Panics - /// - ///Will panic if `self` is not normalized when `glam_assert` is enabled. - mul_vec3(self:Wrapped(Vec3)) -> Wrapped(Vec3), - - ///Multiplies two quaternions. If they each represent a rotation, the result will - ///represent the combined rotation. - /// - ///Note that due to floating point rounding the result may not be perfectly normalized. - /// - ///# Panics - /// - ///Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. - mul_quat(self:self) -> self, - - ///Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. - from_affine3(Wrapped(&Affine3A)) -> self, - - ///Multiplies a quaternion and a 3D vector, returning the rotated vector. - mul_vec3a(self:Wrapped(Vec3A)) -> Wrapped(Vec3A), - - as_f64(self:) -> Wrapped(DQuat), - - ) - + Fields - ( - ) - + BinOps - ( - self Add self -> Wrapped(Quat), - self Sub self -> Wrapped(Quat), - self Div Raw(f32) -> Wrapped(Quat), - self Mul Wrapped(Vec3) -> Wrapped(Vec3), - self Mul self -> Wrapped(Quat), - self Mul Raw(f32) -> Wrapped(Quat), - self Mul Wrapped(Vec3A) -> Wrapped(Vec3A), - ) - + UnaryOps - ( - Neg self -> self - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A quaternion representing an orientation. - /// - ///This quaternion is intended to be of unit length but may denormalize due to - ///floating point "error creep" which can occur when successive quaternion - ///operations are applied. - glam::f64::DQuat : - Clone + - Debug + - Methods - ( - ///Creates a new rotation quaternion. - /// - ///This should generally not be called manually unless you know what you are doing. - ///Use one of the other constructors instead such as `identity` or `from_axis_angle`. - /// - ///`from_xyzw` is mostly used by unit tests and `serde` deserialization. - /// - ///# Preconditions - /// - ///This function does not check if the input is normalized, it is up to the user to - ///provide normalized input or to normalized the resulting quaternion. - from_xyzw(Raw(f64),Raw(f64),Raw(f64),Raw(f64)) -> self, - - ///Creates a new rotation quaternion from a 4D vector. - /// - ///# Preconditions - /// - ///This function does not check if the input is normalized, it is up to the user to - ///provide normalized input or to normalized the resulting quaternion. - from_vec4(Wrapped(DVec4)) -> self, - - ///Create a quaternion for a normalized rotation `axis` and `angle` (in radians). - /// - ///The axis must be a unit vector. - /// - ///# Panics - /// - ///Will panic if `axis` is not normalized when `glam_assert` is enabled. - from_axis_angle(Wrapped(DVec3),Raw(f64)) -> self, - - ///Create a quaternion that rotates `v.length()` radians around `v.normalize()`. - /// - ///`from_scaled_axis(Vec3::ZERO)` results in the identity quaternion. - from_scaled_axis(Wrapped(DVec3)) -> self, - - ///Creates a quaternion from the `angle` (in radians) around the x axis. - from_rotation_x(Raw(f64)) -> self, - - ///Creates a quaternion from the `angle` (in radians) around the y axis. - from_rotation_y(Raw(f64)) -> self, - - ///Creates a quaternion from the `angle` (in radians) around the z axis. - from_rotation_z(Raw(f64)) -> self, - - ///Creates a quaternion from the given Euler rotation sequence and the angles (in radians). - from_euler(Wrapped(EulerRot),Raw(f64),Raw(f64),Raw(f64)) -> self, - - ///Creates a quaternion from a 3x3 rotation matrix. - from_mat3(Wrapped(&DMat3)) -> self, - - ///Creates a quaternion from a 3x3 rotation matrix inside a homogeneous 4x4 matrix. - from_mat4(Wrapped(&DMat4)) -> self, - - ///Gets the minimal rotation for transforming `from` to `to`. The rotation is in the - ///plane spanned by the two vectors. Will rotate at most 180 degrees. - /// - ///The inputs must be unit vectors. - /// - ///`from_rotation_arc(from, to) * from ≈ to`. - /// - ///For near-singular cases (from≈to and from≈-to) the current implementation - ///is only accurate to about 0.001 (for `f32`). - /// - ///# Panics - /// - ///Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. - from_rotation_arc(Wrapped(DVec3),Wrapped(DVec3)) -> self, - - ///Gets the minimal rotation for transforming `from` to either `to` or `-to`. This means - ///that the resulting quaternion will rotate `from` so that it is colinear with `to`. - /// - ///The rotation is in the plane spanned by the two vectors. Will rotate at most 90 - ///degrees. - /// - ///The inputs must be unit vectors. - /// - ///`to.dot(from_rotation_arc_colinear(from, to) * from).abs() ≈ 1`. - /// - ///# Panics - /// - ///Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. - from_rotation_arc_colinear(Wrapped(DVec3),Wrapped(DVec3)) -> self, - - ///Gets the minimal rotation for transforming `from` to `to`. The resulting rotation is - ///around the z axis. Will rotate at most 180 degrees. - /// - ///The inputs must be unit vectors. - /// - ///`from_rotation_arc_2d(from, to) * from ≈ to`. - /// - ///For near-singular cases (from≈to and from≈-to) the current implementation - ///is only accurate to about 0.001 (for `f32`). - /// - ///# Panics - /// - ///Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. - from_rotation_arc_2d(Wrapped(DVec2),Wrapped(DVec2)) -> self, - - ///Returns the rotation axis scaled by the rotation in radians. - to_scaled_axis(self:) -> Wrapped(DVec3), - - ///Returns the vector part of the quaternion. - xyz(self:) -> Wrapped(DVec3), - - ///Returns the quaternion conjugate of `self`. For a unit quaternion the - ///conjugate is also the inverse. - conjugate(self:) -> self, - - ///Returns the inverse of a normalized quaternion. - /// - ///Typically quaternion inverse returns the conjugate of a normalized quaternion. - ///Because `self` is assumed to already be unit length this method *does not* normalize - ///before returning the conjugate. - /// - ///# Panics - /// - ///Will panic if `self` is not normalized when `glam_assert` is enabled. - inverse(self:) -> self, - - ///Computes the dot product of `self` and `rhs`. The dot product is - ///equal to the cosine of the angle between two quaternion rotations. - dot(self:self) -> Raw(f64), - - ///Computes the length of `self`. - length(self:) -> Raw(f64), - - ///Computes the squared length of `self`. - /// - ///This is generally faster than `length()` as it avoids a square - ///root operation. - length_squared(self:) -> Raw(f64), - - ///Computes `1.0 / length()`. - /// - ///For valid results, `self` must _not_ be of length zero. - length_recip(self:) -> Raw(f64), - - ///Returns `self` normalized to length 1.0. - /// - ///For valid results, `self` must _not_ be of length zero. - /// - ///Panics - /// - ///Will panic if `self` is zero length when `glam_assert` is enabled. - normalize(self:) -> self, - - ///Returns `true` if, and only if, all elements are finite. - ///If any element is either `NaN`, positive or negative infinity, this will return `false`. - is_finite(self:) -> Raw(bool), - - is_nan(self:) -> Raw(bool), - - ///Returns whether `self` of length `1.0` or not. - /// - ///Uses a precision threshold of `1e-6`. - is_normalized(self:) -> Raw(bool), - - is_near_identity(self:) -> Raw(bool), - - ///Returns the angle (in radians) for the minimal rotation - ///for transforming this quaternion into another. - /// - ///Both quaternions must be normalized. - /// - ///# Panics - /// - ///Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. - angle_between(self:self) -> Raw(f64), - - ///Returns true if the absolute difference of all elements between `self` and `rhs` - ///is less than or equal to `max_abs_diff`. - /// - ///This can be used to compare if two quaternions contain similar elements. It works - ///best when comparing with a known value. The `max_abs_diff` that should be used used - ///depends on the values being compared against. - /// - ///For more see - ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). - abs_diff_eq(self:self,Raw(f64)) -> Raw(bool), - - ///Performs a linear interpolation between `self` and `rhs` based on - ///the value `s`. - /// - ///When `s` is `0.0`, the result will be equal to `self`. When `s` - ///is `1.0`, the result will be equal to `rhs`. - /// - ///# Panics - /// - ///Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. - lerp(self:self,Raw(f64)) -> self, - - ///Performs a spherical linear interpolation between `self` and `end` - ///based on the value `s`. - /// - ///When `s` is `0.0`, the result will be equal to `self`. When `s` - ///is `1.0`, the result will be equal to `end`. - /// - ///# Panics - /// - ///Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. - slerp(self:self,Raw(f64)) -> self, - - ///Multiplies a quaternion and a 3D vector, returning the rotated vector. - /// - ///# Panics - /// - ///Will panic if `self` is not normalized when `glam_assert` is enabled. - mul_vec3(self:Wrapped(DVec3)) -> Wrapped(DVec3), - - ///Multiplies two quaternions. If they each represent a rotation, the result will - ///represent the combined rotation. - /// - ///Note that due to floating point rounding the result may not be perfectly normalized. - /// - ///# Panics - /// - ///Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. - mul_quat(self:self) -> self, - - ///Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. - from_affine3(Wrapped(&DAffine3)) -> self, - - as_f32(self:) -> Wrapped(Quat), - - ) - + Fields - ( - x: Raw(f64), - y: Raw(f64), - z: Raw(f64), - w: Raw(f64), - ) - + BinOps - ( - self Add self -> Wrapped(DQuat), - self Sub self -> Wrapped(DQuat), - self Div Raw(f64) -> Wrapped(DQuat), - self Mul Raw(f64) -> Wrapped(DQuat), - self Mul self -> Wrapped(DQuat), - self Mul Wrapped(DVec3) -> Wrapped(DVec3), - ) - + UnaryOps - ( - Neg self -> self - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///Euler rotation sequences. - /// - ///The angles are applied starting from the right. - ///E.g. XYZ will first apply the z-axis rotation. - /// - ///YXZ can be used for yaw (y-axis), pitch (x-axis), roll (z-axis). - glam::EulerRot : - Clone + - Debug + - Methods - ( - ) - + Fields - ( - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} -impl_script_newtype! { - #[languages(on_feature(lua))] - ///A rectangle defined by two opposite corners. - /// - ///The rectangle is axis aligned, and defined by its minimum and maximum coordinates, - ///stored in `Rect::min` and `Rect::max`, respectively. The minimum/maximum invariant - ///must be upheld by the user when directly assigning the fields, otherwise some methods - ///produce invalid results. It is generally recommended to use one of the constructor - ///methods instead, which will ensure this invariant is met, unless you already have - ///the minimum and maximum corners. - bevy_math::Rect : - Clone + - Debug + - Methods - ( - ///Create a new rectangle from two corner points. - /// - ///The two points do not need to be the minimum and/or maximum corners. - ///They only need to be two opposite corners. - /// - ///# Examples - /// - ///```rust - ///# use bevy_math::Rect; - ///let r = Rect::new(0., 4., 10., 6.); // w=10 h=2 - ///let r = Rect::new(2., 3., 5., -1.); // w=3 h=4 - ///``` - new(Raw(f32),Raw(f32),Raw(f32),Raw(f32)) -> self, - - ///Create a new rectangle from two corner points. - /// - ///The two points do not need to be the minimum and/or maximum corners. - ///They only need to be two opposite corners. - /// - ///# Examples - /// - ///```rust - ///# use bevy_math::{Rect, Vec2}; - ///// Unit rect from [0,0] to [1,1] - ///let r = Rect::from_corners(Vec2::ZERO, Vec2::ONE); // w=1 h=1 - ///// Same; the points do not need to be ordered - ///let r = Rect::from_corners(Vec2::ONE, Vec2::ZERO); // w=1 h=1 - ///``` - from_corners(Wrapped(Vec2),Wrapped(Vec2)) -> self, - - ///Create a new rectangle from its center and size. - /// - ///# Panics - /// - ///This method panics if any of the components of the size is negative. - /// - ///# Examples - /// - ///```rust - ///# use bevy_math::{Rect, Vec2}; - ///let r = Rect::from_center_size(Vec2::ZERO, Vec2::ONE); // w=1 h=1 - ///assert!(r.min.abs_diff_eq(Vec2::splat(-0.5), 1e-5)); - ///assert!(r.max.abs_diff_eq(Vec2::splat(0.5), 1e-5)); - ///``` - from_center_size(Wrapped(Vec2),Wrapped(Vec2)) -> self, - - ///Create a new rectangle from its center and half-size. - /// - ///# Panics - /// - ///This method panics if any of the components of the half-size is negative. - /// - ///# Examples - /// - ///```rust - ///# use bevy_math::{Rect, Vec2}; - ///let r = Rect::from_center_half_size(Vec2::ZERO, Vec2::ONE); // w=2 h=2 - ///assert!(r.min.abs_diff_eq(Vec2::splat(-1.), 1e-5)); - ///assert!(r.max.abs_diff_eq(Vec2::splat(1.), 1e-5)); - ///``` - from_center_half_size(Wrapped(Vec2),Wrapped(Vec2)) -> self, - - ///Check if the rectangle is empty. - /// - ///# Examples - /// - ///```rust - ///# use bevy_math::{Rect, Vec2}; - ///let r = Rect::from_corners(Vec2::ZERO, Vec2::new(0., 1.)); // w=0 h=1 - ///assert!(r.is_empty()); - ///``` - is_empty(&self:) -> Raw(bool), - - ///Rectangle width (max.x - min.x). - /// - ///# Examples - /// - ///```rust - ///# use bevy_math::Rect; - ///let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 - ///assert!((r.width() - 5.).abs() <= 1e-5); - ///``` - width(&self:) -> Raw(f32), - - ///Rectangle height (max.y - min.y). - /// - ///# Examples - /// - ///```rust - ///# use bevy_math::Rect; - ///let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 - ///assert!((r.height() - 1.).abs() <= 1e-5); - ///``` - height(&self:) -> Raw(f32), - - ///Rectangle size. - /// - ///# Examples - /// - ///```rust - ///# use bevy_math::{Rect, Vec2}; - ///let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 - ///assert!(r.size().abs_diff_eq(Vec2::new(5., 1.), 1e-5)); - ///``` - size(&self:) -> Wrapped(Vec2), - - ///Rectangle half-size. - /// - ///# Examples - /// - ///```rust - ///# use bevy_math::{Rect, Vec2}; - ///let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 - ///assert!(r.half_size().abs_diff_eq(Vec2::new(2.5, 0.5), 1e-5)); - ///``` - half_size(&self:) -> Wrapped(Vec2), - - ///The center point of the rectangle. - /// - ///# Examples - /// - ///```rust - ///# use bevy_math::{Rect, Vec2}; - ///let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 - ///assert!(r.center().abs_diff_eq(Vec2::new(2.5, 0.5), 1e-5)); - ///``` - center(&self:) -> Wrapped(Vec2), - - ///Check if a point lies within this rectangle, inclusive of its edges. - /// - ///# Examples - /// - ///```rust - ///# use bevy_math::Rect; - ///let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 - ///assert!(r.contains(r.center())); - ///assert!(r.contains(r.min)); - ///assert!(r.contains(r.max)); - ///``` - contains(&self:Wrapped(Vec2)) -> Raw(bool), - - ///Build a new rectangle formed of the union of this rectangle and another rectangle. - /// - ///The union is the smallest rectangle enclosing both rectangles. - /// - ///# Examples - /// - ///```rust - ///# use bevy_math::{Rect, Vec2}; - ///let r1 = Rect::new(0., 0., 5., 1.); // w=5 h=1 - ///let r2 = Rect::new(1., -1., 3., 3.); // w=2 h=4 - ///let r = r1.union(r2); - ///assert!(r.min.abs_diff_eq(Vec2::new(0., -1.), 1e-5)); - ///assert!(r.max.abs_diff_eq(Vec2::new(5., 3.), 1e-5)); - ///``` - union(&self:self) -> self, - - ///Build a new rectangle formed of the union of this rectangle and a point. - /// - ///The union is the smallest rectangle enclosing both the rectangle and the point. If the - ///point is already inside the rectangle, this method returns a copy of the rectangle. - /// - ///# Examples - /// - ///```rust - ///# use bevy_math::{Rect, Vec2}; - ///let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 - ///let u = r.union_point(Vec2::new(3., 6.)); - ///assert!(u.min.abs_diff_eq(Vec2::ZERO, 1e-5)); - ///assert!(u.max.abs_diff_eq(Vec2::new(5., 6.), 1e-5)); - ///``` - union_point(&self:Wrapped(Vec2)) -> self, - - ///Build a new rectangle formed of the intersection of this rectangle and another rectangle. - /// - ///The intersection is the largest rectangle enclosed in both rectangles. If the intersection - ///is empty, this method returns an empty rectangle ([`Rect::is_empty()`] returns `true`), but - ///the actual values of [`Rect::min`] and [`Rect::max`] are implementation-dependent. - /// - ///# Examples - /// - ///```rust - ///# use bevy_math::{Rect, Vec2}; - ///let r1 = Rect::new(0., 0., 5., 1.); // w=5 h=1 - ///let r2 = Rect::new(1., -1., 3., 3.); // w=2 h=4 - ///let r = r1.intersect(r2); - ///assert!(r.min.abs_diff_eq(Vec2::new(1., 0.), 1e-5)); - ///assert!(r.max.abs_diff_eq(Vec2::new(3., 1.), 1e-5)); - ///``` - intersect(&self:self) -> self, - - ///Create a new rectangle with a constant inset. - /// - ///The inset is the extra border on all sides. A positive inset produces a larger rectangle, - ///while a negative inset is allowed and produces a smaller rectangle. If the inset is negative - ///and its absolute value is larger than the rectangle half-size, the created rectangle is empty. - /// - ///# Examples - /// - ///```rust - ///# use bevy_math::{Rect, Vec2}; - ///let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 - ///let r2 = r.inset(3.); // w=11 h=7 - ///assert!(r2.min.abs_diff_eq(Vec2::splat(-3.), 1e-5)); - ///assert!(r2.max.abs_diff_eq(Vec2::new(8., 4.), 1e-5)); - /// - ///let r = Rect::new(0., -1., 6., 7.); // w=6 h=8 - ///let r2 = r.inset(-2.); // w=11 h=7 - ///assert!(r2.min.abs_diff_eq(Vec2::new(2., 1.), 1e-5)); - ///assert!(r2.max.abs_diff_eq(Vec2::new(4., 5.), 1e-5)); - ///``` - inset(&self:Raw(f32)) -> self, - - ) - + Fields - ( - /// The minimum corner point of the rect. - min: Wrapped(Vec2), - /// The maximum corner point of the rect. - max: Wrapped(Vec2), - ) - + BinOps - ( - ) - + UnaryOps - ( - ) - lua impl - { - } -} + + ///See also [`Color::rgba`], [`Color::rgb_u8`], [`Color::hex`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn rgb ( + + + + r : f32, + + + + + + g : f32, + + + + + + b : f32, + + + + ) + + + -> bevy::render::color::Color + + ; +"#, + r#" + + ///New `Color` from sRGB colorspace. + + /// + + ///# Arguments + + /// + + ///* `r` - Red channel. [0.0, 1.0] + + ///* `g` - Green channel. [0.0, 1.0] + + ///* `b` - Blue channel. [0.0, 1.0] + + ///* `a` - Alpha channel. [0.0, 1.0] + + /// + + ///See also [`Color::rgb`], [`Color::rgba_u8`], [`Color::hex`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn rgba ( + + + + r : f32, + + + + + + g : f32, + + + + + + b : f32, + + + + + + a : f32, + + + + ) + + + -> bevy::render::color::Color + + ; +"#, + r#" + + ///New `Color` from linear RGB colorspace. + + /// + + ///# Arguments + + /// + + ///* `r` - Red channel. [0.0, 1.0] + + ///* `g` - Green channel. [0.0, 1.0] + + ///* `b` - Blue channel. [0.0, 1.0] + + /// + + ///See also [`Color::rgb`], [`Color::rgba_linear`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn rgb_linear ( + + + + r : f32, + + + + + + g : f32, + + + + + + b : f32, + + + + ) + + + -> bevy::render::color::Color + + ; +"#, + r#" + + ///New `Color` from linear RGB colorspace. + + /// + + ///# Arguments + + /// + + ///* `r` - Red channel. [0.0, 1.0] + + ///* `g` - Green channel. [0.0, 1.0] + + ///* `b` - Blue channel. [0.0, 1.0] + + ///* `a` - Alpha channel. [0.0, 1.0] + + /// + + ///See also [`Color::rgba`], [`Color::rgb_linear`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn rgba_linear ( + + + + r : f32, + + + + + + g : f32, + + + + + + b : f32, + + + + + + a : f32, + + + + ) + + + -> bevy::render::color::Color + + ; +"#, + r#" + + ///New `Color` with HSL representation in sRGB colorspace. + + /// + + ///# Arguments + + /// + + ///* `hue` - Hue channel. [0.0, 360.0] + + ///* `saturation` - Saturation channel. [0.0, 1.0] + + ///* `lightness` - Lightness channel. [0.0, 1.0] + + /// + + ///See also [`Color::hsla`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn hsl ( + + + + hue : f32, + + + + + + saturation : f32, + + + + + + lightness : f32, + + + + ) + + + -> bevy::render::color::Color + + ; +"#, + r#" + + ///New `Color` with HSL representation in sRGB colorspace. + + /// + + ///# Arguments + + /// + + ///* `hue` - Hue channel. [0.0, 360.0] + + ///* `saturation` - Saturation channel. [0.0, 1.0] + + ///* `lightness` - Lightness channel. [0.0, 1.0] + + ///* `alpha` - Alpha channel. [0.0, 1.0] + + /// + + ///See also [`Color::hsl`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn hsla ( + + + + hue : f32, + + + + + + saturation : f32, + + + + + + lightness : f32, + + + + + + alpha : f32, + + + + ) + + + -> bevy::render::color::Color + + ; +"#, + r#" + + ///New `Color` with LCH representation in sRGB colorspace. + + /// + + ///# Arguments + + /// + + ///* `lightness` - Lightness channel. [0.0, 1.5] + + ///* `chroma` - Chroma channel. [0.0, 1.5] + + ///* `hue` - Hue channel. [0.0, 360.0] + + /// + + ///See also [`Color::lcha`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn lch ( + + + + lightness : f32, + + + + + + chroma : f32, + + + + + + hue : f32, + + + + ) + + + -> bevy::render::color::Color + + ; +"#, + r#" + + ///New `Color` with LCH representation in sRGB colorspace. + + /// + + ///# Arguments + + /// + + ///* `lightness` - Lightness channel. [0.0, 1.5] + + ///* `chroma` - Chroma channel. [0.0, 1.5] + + ///* `hue` - Hue channel. [0.0, 360.0] + + ///* `alpha` - Alpha channel. [0.0, 1.0] + + /// + + ///See also [`Color::lch`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn lcha ( + + + + lightness : f32, + + + + + + chroma : f32, + + + + + + hue : f32, + + + + + + alpha : f32, + + + + ) + + + -> bevy::render::color::Color + + ; +"#, + r#" + + ///New `Color` from sRGB colorspace. + + /// + + ///# Arguments + + /// + + ///* `r` - Red channel. [0, 255] + + ///* `g` - Green channel. [0, 255] + + ///* `b` - Blue channel. [0, 255] + + /// + + ///See also [`Color::rgb`], [`Color::rgba_u8`], [`Color::hex`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn rgb_u8 ( + + + + r : u8, + + + + + + g : u8, + + + + + + b : u8, + + + + ) + + + -> bevy::render::color::Color + + ; +"#, + r#" + + ///New `Color` from sRGB colorspace. + + /// + + ///# Arguments + + /// + + ///* `r` - Red channel. [0, 255] + + ///* `g` - Green channel. [0, 255] + + ///* `b` - Blue channel. [0, 255] + + ///* `a` - Alpha channel. [0, 255] + + /// + + ///See also [`Color::rgba`], [`Color::rgb_u8`], [`Color::hex`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn rgba_u8 ( + + + + r : u8, + + + + + + g : u8, + + + + + + b : u8, + + + + + + a : u8, + + + + ) + + + -> bevy::render::color::Color + + ; +"#, + r#" + + ///Get red in sRGB colorspace. + + #[lua( + + + + )] + fn r ( + + + &self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Get green in sRGB colorspace. + + #[lua( + + + + )] + fn g ( + + + &self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Get blue in sRGB colorspace. + + #[lua( + + + + )] + fn b ( + + + &self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns this color with red set to a new value in sRGB colorspace. + + #[lua( + + + + output(proxy), + + )] + fn with_r ( + + + self, + + + + + r : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns this color with green set to a new value in sRGB colorspace. + + #[lua( + + + + output(proxy), + + )] + fn with_g ( + + + self, + + + + + g : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns this color with blue set to a new value in sRGB colorspace. + + #[lua( + + + + output(proxy), + + )] + fn with_b ( + + + self, + + + + + b : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Get alpha. + + #[lua( + + + + )] + fn a ( + + + &self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns this color with a new alpha value. + + #[lua( + + + + output(proxy), + + )] + fn with_a ( + + + self, + + + + + a : f32, + + + + ) + + + -> Self + + ; +"#, + ] +)] +pub struct Color; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::render::primitives::Aabb", + functions[r#" + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_min_max ( + + + + #[proxy] + + minimum : bevy::math::f32::Vec3, + + + + + + #[proxy] + + maximum : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + #[lua( + + + + output(proxy), + + )] + fn min ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + + output(proxy), + + )] + fn max ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + ] +)] +pub struct Aabb; +#[derive(LuaProxy)] +#[proxy(derive(debug), remote = "bevy::render::primitives::CubemapFrusta", functions[])] +pub struct CubemapFrusta; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::render::primitives::Frustum", + functions[r#" + + ///Returns a frustum derived from `view_projection`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_view_projection ( + + + + #[proxy] + + view_projection : &bevy::math::f32::Mat4, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a frustum derived from `view_projection`, + + ///but with a custom far plane. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_view_projection_custom_far ( + + + + #[proxy] + + view_projection : &bevy::math::f32::Mat4, + + + + + + #[proxy] + + view_translation : &bevy::math::f32::Vec3, + + + + + + #[proxy] + + view_backward : &bevy::math::f32::Vec3, + + + + + + far : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Checks if an Oriented Bounding Box (obb) intersects the frustum. + + #[lua( + + + + )] + fn intersects_obb ( + + + &self, + + + + + #[proxy] + + aabb : &bevy::render::primitives::Aabb, + + + + + + #[proxy] + + model_to_world : &bevy::math::f32::Mat4, + + + + + + intersect_near : bool, + + + + + + intersect_far : bool, + + + + ) + + + -> bool + + ; +"#, + ] +)] +pub struct Frustum; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::render::view::Msaa", + functions[r#" + + #[lua( + + + + )] + fn samples ( + + + &self, + + + ) + + + -> u32 + + ; +"#, + ] +)] +pub struct Msaa; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::render::camera::Camera", + functions[r#" + + ///The projection matrix computed using this camera's [`CameraProjection`]. + + #[lua( + + + + output(proxy), + + )] + fn projection_matrix ( + + + &self, + + + ) + + + -> bevy::math::f32::Mat4 + + ; +"#, + ] +)] +pub struct Camera; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::render::camera::RenderTarget", + functions[] +)] +pub struct RenderTarget; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::render::camera::Viewport", functions[])] +pub struct Viewport; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::render::camera::Projection", + functions[r#" + + #[lua( + + + as_trait="bevy::render::camera::CameraProjection", + + + output(proxy), + + )] + fn get_projection_matrix ( + + + &self, + + + ) + + + -> bevy::math::f32::Mat4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::render::camera::CameraProjection", + + + )] + fn update ( + + + &mut self, + + + + + width : f32, + + + + + + height : f32, + + + + ) + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::render::camera::CameraProjection", + + + )] + fn far ( + + + &self, + + + ) + + + -> f32 + + ; +"#, + ] +)] +pub struct Projection; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::render::camera::OrthographicProjection", + functions[r#" + + #[lua( + + + as_trait="bevy::render::camera::CameraProjection", + + + output(proxy), + + )] + fn get_projection_matrix ( + + + &self, + + + ) + + + -> bevy::math::f32::Mat4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::render::camera::CameraProjection", + + + )] + fn update ( + + + &mut self, + + + + + width : f32, + + + + + + height : f32, + + + + ) + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::render::camera::CameraProjection", + + + )] + fn far ( + + + &self, + + + ) + + + -> f32 + + ; +"#, + ] +)] +pub struct OrthographicProjection; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::render::camera::PerspectiveProjection", + functions[r#" + + #[lua( + + + as_trait="bevy::render::camera::CameraProjection", + + + output(proxy), + + )] + fn get_projection_matrix ( + + + &self, + + + ) + + + -> bevy::math::f32::Mat4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::render::camera::CameraProjection", + + + )] + fn update ( + + + &mut self, + + + + + width : f32, + + + + + + height : f32, + + + + ) + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::render::camera::CameraProjection", + + + )] + fn far ( + + + &self, + + + ) + + + -> f32 + + ; +"#, + ] +)] +pub struct PerspectiveProjection; +#[derive(LuaProxy)] +#[proxy(derive(), remote = "bevy::render::camera::CameraRenderGraph", functions[])] +pub struct CameraRenderGraph; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::asset::AssetPathId", + functions[r#" + + ///Gets the id of the source path. + + #[lua( + + + + output(proxy), + + )] + fn source_path_id ( + + + &self, + + + ) + + + -> bevy::asset::SourcePathId + + ; +"#, + r#" + + ///Gets the id of the sub-asset label. + + #[lua( + + + + output(proxy), + + )] + fn label_id ( + + + &self, + + + ) + + + -> bevy::asset::LabelId + + ; +"#, + ] +)] +pub struct AssetPathId; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::asset::LabelId", functions[])] +pub struct LabelId; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::asset::SourcePathId", functions[])] +pub struct SourcePathId; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::asset::HandleId", functions[])] +pub struct HandleId; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::f32::Vec2", + functions[r#" + + ///Creates a new vector. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn new ( + + + + x : f32, + + + + + + y : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector with all elements set to `v`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn splat ( + + + + v : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use + + ///for each element of `self`. + + /// + + ///A true element in the mask uses the corresponding element from `if_true`, and false + + ///uses the element from `if_false`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn select ( + + + + #[proxy] + + mask : bevy::math::bool::BVec2, + + + + + + #[proxy] + + if_true : Self, + + + + + + #[proxy] + + if_false : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3D vector from `self` and the given `z` value. + + #[lua( + + + + output(proxy), + + )] + fn extend ( + + + self, + + + + + z : f32, + + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Computes the dot product of `self` and `rhs`. + + #[lua( + + + + )] + fn dot ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua( + + + + output(proxy), + + )] + fn dot_into_vec ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the minimum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn min ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the maximum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn max ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Component-wise clamping of values, similar to [`f32::clamp`]. + + /// + + ///Each element in `min` must be less-or-equal to the corresponding element in `max`. + + /// + + ///# Panics + + /// + + ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn clamp ( + + + self, + + + + + #[proxy] + + min : Self, + + + + + + #[proxy] + + max : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the horizontal minimum of `self`. + + /// + + ///In other words this computes `min(x, y, ..)`. + + #[lua( + + + + )] + fn min_element ( + + + self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns the horizontal maximum of `self`. + + /// + + ///In other words this computes `max(x, y, ..)`. + + #[lua( + + + + )] + fn max_element ( + + + self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `==` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpeq ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `!=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpne ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpge ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpgt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmple ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmplt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Returns a vector containing the absolute value of each element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn abs ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with elements representing the sign of `self`. + + /// + + ///- `1.0` if the number is positive, `+0.0` or `INFINITY` + + ///- `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` + + ///- `NAN` if the number is `NAN` + + #[lua( + + + + output(proxy), + + )] + fn signum ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with signs of `rhs` and the magnitudes of `self`. + + #[lua( + + + + output(proxy), + + )] + fn copysign ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a bitmask with the lowest 2 bits set to the sign bits from the elements of `self`. + + /// + + ///A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes + + ///into the first lowest bit, element `y` into the second, etc. + + #[lua( + + + + )] + fn is_negative_bitmask ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Returns `true` if, and only if, all elements are finite. If any element is either + + ///`NaN`, positive or negative infinity, this will return `false`. + + #[lua( + + + + )] + fn is_finite ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns `true` if any elements are `NaN`. + + #[lua( + + + + )] + fn is_nan ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Performs `is_nan` on each element of self, returning a vector mask of the results. + + /// + + ///In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. + + #[lua( + + + + output(proxy), + + )] + fn is_nan_mask ( + + + self, + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Computes the length of `self`. + + #[lua( + + + + )] + fn length ( + + + self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Computes the squared length of `self`. + + /// + + ///This is faster than `length()` as it avoids a square root operation. + + #[lua( + + + + )] + fn length_squared ( + + + self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Computes `1.0 / length()`. + + /// + + ///For valid results, `self` must _not_ be of length zero. + + #[lua( + + + + )] + fn length_recip ( + + + self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Computes the Euclidean distance between two points in space. + + #[lua( + + + + )] + fn distance ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Compute the squared euclidean distance between two points in space. + + #[lua( + + + + )] + fn distance_squared ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns `self` normalized to length 1.0. + + /// + + ///For valid results, `self` must _not_ be of length zero, nor very close to zero. + + /// + + ///See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. + + /// + + ///Panics + + /// + + ///Will panic if `self` is zero length when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn normalize ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns `self` normalized to length 1.0 if possible, else returns zero. + + /// + + ///In particular, if the input is zero (or very close to zero), or non-finite, + + ///the result of this operation will be zero. + + /// + + ///See also [`Self::try_normalize()`]. + + #[lua( + + + + output(proxy), + + )] + fn normalize_or_zero ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns whether `self` is length `1.0` or not. + + /// + + ///Uses a precision threshold of `1e-6`. + + #[lua( + + + + )] + fn is_normalized ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns the vector projection of `self` onto `rhs`. + + /// + + ///`rhs` must be of non-zero length. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` is zero length when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn project_onto ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the vector rejection of `self` from `rhs`. + + /// + + ///The vector rejection is the vector perpendicular to the projection of `self` onto + + ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. + + /// + + ///`rhs` must be of non-zero length. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` has a length of zero when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn reject_from ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the vector projection of `self` onto `rhs`. + + /// + + ///`rhs` must be normalized. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn project_onto_normalized ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the vector rejection of `self` from `rhs`. + + /// + + ///The vector rejection is the vector perpendicular to the projection of `self` onto + + ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. + + /// + + ///`rhs` must be normalized. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn reject_from_normalized ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the nearest integer to a number for each element of `self`. + + ///Round half-way cases away from 0.0. + + #[lua( + + + + output(proxy), + + )] + fn round ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the largest integer less than or equal to a number for each + + ///element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn floor ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the smallest integer greater than or equal to a number for + + ///each element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn ceil ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the integer part each element of `self`. This means numbers are + + ///always truncated towards zero. + + #[lua( + + + + output(proxy), + + )] + fn trunc ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the fractional part of the vector, e.g. `self - + + ///self.floor()`. + + /// + + ///Note that this is fast but not precise for large numbers. + + #[lua( + + + + output(proxy), + + )] + fn fract ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing `e^self` (the exponential function) for each element of + + ///`self`. + + #[lua( + + + + output(proxy), + + )] + fn exp ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing each element of `self` raised to the power of `n`. + + #[lua( + + + + output(proxy), + + )] + fn powf ( + + + self, + + + + + n : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the reciprocal `1.0/n` of each element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn recip ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Performs a linear interpolation between `self` and `rhs` based on the value `s`. + + /// + + ///When `s` is `0.0`, the result will be equal to `self`. When `s` is `1.0`, the result + + ///will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly + + ///extrapolated. + + #[lua( + + + + output(proxy), + + )] + fn lerp ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + + + s : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns true if the absolute difference of all elements between `self` and `rhs` is + + ///less than or equal to `max_abs_diff`. + + /// + + ///This can be used to compare if two vectors contain similar elements. It works best when + + ///comparing with a known value. The `max_abs_diff` that should be used used depends on + + ///the values being compared against. + + /// + + ///For more see + + ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua( + + + + )] + fn abs_diff_eq ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + + + max_abs_diff : f32, + + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns a vector with a length no less than `min` and no more than `max` + + /// + + ///# Panics + + /// + + ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn clamp_length ( + + + self, + + + + + min : f32, + + + + + + max : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with a length no more than `max` + + #[lua( + + + + output(proxy), + + )] + fn clamp_length_max ( + + + self, + + + + + max : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with a length no less than `min` + + #[lua( + + + + output(proxy), + + )] + fn clamp_length_min ( + + + self, + + + + + min : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding + + ///error, yielding a more accurate result than an unfused multiply-add. + + /// + + ///Using `mul_add` *may* be more performant than an unfused multiply-add if the target + + ///architecture has a dedicated fma CPU instruction. However, this is not always true, + + ///and will be heavily dependant on designing algorithms with specific target hardware in + + ///mind. + + #[lua( + + + + output(proxy), + + )] + fn mul_add ( + + + self, + + + + + #[proxy] + + a : Self, + + + + + + #[proxy] + + b : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 2D vector containing `[angle.cos(), angle.sin()]`. This can be used in + + ///conjunction with the [`rotate()`][Self::rotate()] method, e.g. + + ///`Vec2::from_angle(PI).rotate(Vec2::Y)` will create the vector `[-1, 0]` + + ///and rotate [`Vec2::Y`] around it returning `-Vec2::Y`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_angle ( + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the angle (in radians) between `self` and `rhs` in the range `[-π, +π]`. + + /// + + ///The inputs do not need to be unit vectors however they must be non-zero. + + #[lua( + + + + )] + fn angle_between ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns a vector that is equal to `self` rotated by 90 degrees. + + #[lua( + + + + output(proxy), + + )] + fn perp ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///The perpendicular dot product of `self` and `rhs`. + + ///Also known as the wedge product, 2D cross product, and determinant. + + #[lua( + + + + )] + fn perp_dot ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns `rhs` rotated by the angle of `self`. If `self` is normalized, + + ///then this just rotation. This is what you usually want. Otherwise, + + ///it will be like a rotation with a multiplication by `self`'s length. + + #[lua( + + + + output(proxy), + + )] + fn rotate ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Casts all elements of `self` to `f64`. + + #[lua( + + + + output(proxy), + + )] + fn as_dvec2 ( + + + &self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + ///Casts all elements of `self` to `i32`. + + #[lua( + + + + output(proxy), + + )] + fn as_ivec2 ( + + + &self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + ///Casts all elements of `self` to `u32`. + + #[lua( + + + + output(proxy), + + )] + fn as_uvec2 ( + + + &self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xxxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xxxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xxyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xxyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xyxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xyxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xyyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xyyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yxxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yxxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yxyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yxyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yyxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yyxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yyyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yyyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + ] +)] +pub struct Vec2; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::f32::Vec3", + functions[r#" + + ///Creates a new vector. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn new ( + + + + x : f32, + + + + + + y : f32, + + + + + + z : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector with all elements set to `v`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn splat ( + + + + v : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use + + ///for each element of `self`. + + /// + + ///A true element in the mask uses the corresponding element from `if_true`, and false + + ///uses the element from `if_false`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn select ( + + + + #[proxy] + + mask : bevy::math::bool::BVec3, + + + + + + #[proxy] + + if_true : Self, + + + + + + #[proxy] + + if_false : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 4D vector from `self` and the given `w` value. + + #[lua( + + + + output(proxy), + + )] + fn extend ( + + + self, + + + + + w : f32, + + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + ///Creates a 2D vector from the `x` and `y` elements of `self`, discarding `z`. + + /// + + ///Truncation may also be performed by using [`self.xy()`][crate::swizzles::Vec3Swizzles::xy()]. + + #[lua( + + + + output(proxy), + + )] + fn truncate ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + ///Computes the dot product of `self` and `rhs`. + + #[lua( + + + + )] + fn dot ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua( + + + + output(proxy), + + )] + fn dot_into_vec ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Computes the cross product of `self` and `rhs`. + + #[lua( + + + + output(proxy), + + )] + fn cross ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the minimum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn min ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the maximum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn max ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Component-wise clamping of values, similar to [`f32::clamp`]. + + /// + + ///Each element in `min` must be less-or-equal to the corresponding element in `max`. + + /// + + ///# Panics + + /// + + ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn clamp ( + + + self, + + + + + #[proxy] + + min : Self, + + + + + + #[proxy] + + max : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the horizontal minimum of `self`. + + /// + + ///In other words this computes `min(x, y, ..)`. + + #[lua( + + + + )] + fn min_element ( + + + self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns the horizontal maximum of `self`. + + /// + + ///In other words this computes `max(x, y, ..)`. + + #[lua( + + + + )] + fn max_element ( + + + self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `==` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpeq ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `!=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpne ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpge ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpgt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmple ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmplt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Returns a vector containing the absolute value of each element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn abs ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with elements representing the sign of `self`. + + /// + + ///- `1.0` if the number is positive, `+0.0` or `INFINITY` + + ///- `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` + + ///- `NAN` if the number is `NAN` + + #[lua( + + + + output(proxy), + + )] + fn signum ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with signs of `rhs` and the magnitudes of `self`. + + #[lua( + + + + output(proxy), + + )] + fn copysign ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of `self`. + + /// + + ///A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes + + ///into the first lowest bit, element `y` into the second, etc. + + #[lua( + + + + )] + fn is_negative_bitmask ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Returns `true` if, and only if, all elements are finite. If any element is either + + ///`NaN`, positive or negative infinity, this will return `false`. + + #[lua( + + + + )] + fn is_finite ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns `true` if any elements are `NaN`. + + #[lua( + + + + )] + fn is_nan ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Performs `is_nan` on each element of self, returning a vector mask of the results. + + /// + + ///In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. + + #[lua( + + + + output(proxy), + + )] + fn is_nan_mask ( + + + self, + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Computes the length of `self`. + + #[lua( + + + + )] + fn length ( + + + self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Computes the squared length of `self`. + + /// + + ///This is faster than `length()` as it avoids a square root operation. + + #[lua( + + + + )] + fn length_squared ( + + + self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Computes `1.0 / length()`. + + /// + + ///For valid results, `self` must _not_ be of length zero. + + #[lua( + + + + )] + fn length_recip ( + + + self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Computes the Euclidean distance between two points in space. + + #[lua( + + + + )] + fn distance ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Compute the squared euclidean distance between two points in space. + + #[lua( + + + + )] + fn distance_squared ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns `self` normalized to length 1.0. + + /// + + ///For valid results, `self` must _not_ be of length zero, nor very close to zero. + + /// + + ///See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. + + /// + + ///Panics + + /// + + ///Will panic if `self` is zero length when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn normalize ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns `self` normalized to length 1.0 if possible, else returns zero. + + /// + + ///In particular, if the input is zero (or very close to zero), or non-finite, + + ///the result of this operation will be zero. + + /// + + ///See also [`Self::try_normalize()`]. + + #[lua( + + + + output(proxy), + + )] + fn normalize_or_zero ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns whether `self` is length `1.0` or not. + + /// + + ///Uses a precision threshold of `1e-6`. + + #[lua( + + + + )] + fn is_normalized ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns the vector projection of `self` onto `rhs`. + + /// + + ///`rhs` must be of non-zero length. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` is zero length when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn project_onto ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the vector rejection of `self` from `rhs`. + + /// + + ///The vector rejection is the vector perpendicular to the projection of `self` onto + + ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. + + /// + + ///`rhs` must be of non-zero length. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` has a length of zero when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn reject_from ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the vector projection of `self` onto `rhs`. + + /// + + ///`rhs` must be normalized. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn project_onto_normalized ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the vector rejection of `self` from `rhs`. + + /// + + ///The vector rejection is the vector perpendicular to the projection of `self` onto + + ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. + + /// + + ///`rhs` must be normalized. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn reject_from_normalized ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the nearest integer to a number for each element of `self`. + + ///Round half-way cases away from 0.0. + + #[lua( + + + + output(proxy), + + )] + fn round ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the largest integer less than or equal to a number for each + + ///element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn floor ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the smallest integer greater than or equal to a number for + + ///each element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn ceil ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the integer part each element of `self`. This means numbers are + + ///always truncated towards zero. + + #[lua( + + + + output(proxy), + + )] + fn trunc ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the fractional part of the vector, e.g. `self - + + ///self.floor()`. + + /// + + ///Note that this is fast but not precise for large numbers. + + #[lua( + + + + output(proxy), + + )] + fn fract ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing `e^self` (the exponential function) for each element of + + ///`self`. + + #[lua( + + + + output(proxy), + + )] + fn exp ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing each element of `self` raised to the power of `n`. + + #[lua( + + + + output(proxy), + + )] + fn powf ( + + + self, + + + + + n : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the reciprocal `1.0/n` of each element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn recip ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Performs a linear interpolation between `self` and `rhs` based on the value `s`. + + /// + + ///When `s` is `0.0`, the result will be equal to `self`. When `s` is `1.0`, the result + + ///will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly + + ///extrapolated. + + #[lua( + + + + output(proxy), + + )] + fn lerp ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + + + s : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns true if the absolute difference of all elements between `self` and `rhs` is + + ///less than or equal to `max_abs_diff`. + + /// + + ///This can be used to compare if two vectors contain similar elements. It works best when + + ///comparing with a known value. The `max_abs_diff` that should be used used depends on + + ///the values being compared against. + + /// + + ///For more see + + ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua( + + + + )] + fn abs_diff_eq ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + + + max_abs_diff : f32, + + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns a vector with a length no less than `min` and no more than `max` + + /// + + ///# Panics + + /// + + ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn clamp_length ( + + + self, + + + + + min : f32, + + + + + + max : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with a length no more than `max` + + #[lua( + + + + output(proxy), + + )] + fn clamp_length_max ( + + + self, + + + + + max : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with a length no less than `min` + + #[lua( + + + + output(proxy), + + )] + fn clamp_length_min ( + + + self, + + + + + min : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding + + ///error, yielding a more accurate result than an unfused multiply-add. + + /// + + ///Using `mul_add` *may* be more performant than an unfused multiply-add if the target + + ///architecture has a dedicated fma CPU instruction. However, this is not always true, + + ///and will be heavily dependant on designing algorithms with specific target hardware in + + ///mind. + + #[lua( + + + + output(proxy), + + )] + fn mul_add ( + + + self, + + + + + #[proxy] + + a : Self, + + + + + + #[proxy] + + b : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the angle (in radians) between two vectors. + + /// + + ///The inputs do not need to be unit vectors however they must be non-zero. + + #[lua( + + + + )] + fn angle_between ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns some vector that is orthogonal to the given one. + + /// + + ///The input vector must be finite and non-zero. + + /// + + ///The output vector is not necessarily unit length. For that use + + ///[`Self::any_orthonormal_vector()`] instead. + + #[lua( + + + + output(proxy), + + )] + fn any_orthogonal_vector ( + + + &self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns any unit vector that is orthogonal to the given one. + + /// + + ///The input vector must be unit length. + + /// + + ///# Panics + + /// + + ///Will panic if `self` is not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn any_orthonormal_vector ( + + + &self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Casts all elements of `self` to `f64`. + + #[lua( + + + + output(proxy), + + )] + fn as_dvec3 ( + + + &self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + ///Casts all elements of `self` to `i32`. + + #[lua( + + + + output(proxy), + + )] + fn as_ivec3 ( + + + &self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + ///Casts all elements of `self` to `u32`. + + #[lua( + + + + output(proxy), + + )] + fn as_uvec3 ( + + + &self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + ] +)] +pub struct Vec3; + +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::f32::Vec3A", + functions[r#" + + ///Creates a new vector. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn new ( + + + + x : f32, + + + + + + y : f32, + + + + + + z : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector with all elements set to `v`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn splat ( + + + + v : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use + + ///for each element of `self`. + + /// + + ///A true element in the mask uses the corresponding element from `if_true`, and false + + ///uses the element from `if_false`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn select ( + + + + #[proxy] + + mask : bevy::math::bool::BVec3A, + + + + + + #[proxy] + + if_true : Self, + + + + + + #[proxy] + + if_false : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 4D vector from `self` and the given `w` value. + + #[lua( + + + + output(proxy), + + )] + fn extend ( + + + self, + + + + + w : f32, + + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + ///Creates a 2D vector from the `x` and `y` elements of `self`, discarding `z`. + + /// + + ///Truncation may also be performed by using [`self.xy()`][crate::swizzles::Vec3Swizzles::xy()]. + + #[lua( + + + + output(proxy), + + )] + fn truncate ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + ///Computes the dot product of `self` and `rhs`. + + #[lua( + + + + )] + fn dot ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua( + + + + output(proxy), + + )] + fn dot_into_vec ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Computes the cross product of `self` and `rhs`. + + #[lua( + + + + output(proxy), + + )] + fn cross ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the minimum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn min ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the maximum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn max ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Component-wise clamping of values, similar to [`f32::clamp`]. + + /// + + ///Each element in `min` must be less-or-equal to the corresponding element in `max`. + + /// + + ///# Panics + + /// + + ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn clamp ( + + + self, + + + + + #[proxy] + + min : Self, + + + + + + #[proxy] + + max : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the horizontal minimum of `self`. + + /// + + ///In other words this computes `min(x, y, ..)`. + + #[lua( + + + + )] + fn min_element ( + + + self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns the horizontal maximum of `self`. + + /// + + ///In other words this computes `max(x, y, ..)`. + + #[lua( + + + + )] + fn max_element ( + + + self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `==` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpeq ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3A + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `!=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpne ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3A + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpge ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3A + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpgt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3A + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmple ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3A + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmplt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3A + + ; +"#, + r#" + + ///Returns a vector containing the absolute value of each element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn abs ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with elements representing the sign of `self`. + + /// + + ///- `1.0` if the number is positive, `+0.0` or `INFINITY` + + ///- `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` + + ///- `NAN` if the number is `NAN` + + #[lua( + + + + output(proxy), + + )] + fn signum ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with signs of `rhs` and the magnitudes of `self`. + + #[lua( + + + + output(proxy), + + )] + fn copysign ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of `self`. + + /// + + ///A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes + + ///into the first lowest bit, element `y` into the second, etc. + + #[lua( + + + + )] + fn is_negative_bitmask ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Returns `true` if, and only if, all elements are finite. If any element is either + + ///`NaN`, positive or negative infinity, this will return `false`. + + #[lua( + + + + )] + fn is_finite ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns `true` if any elements are `NaN`. + + #[lua( + + + + )] + fn is_nan ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Performs `is_nan` on each element of self, returning a vector mask of the results. + + /// + + ///In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. + + #[lua( + + + + output(proxy), + + )] + fn is_nan_mask ( + + + self, + + + ) + + + -> bevy::math::bool::BVec3A + + ; +"#, + r#" + + ///Computes the length of `self`. + + #[lua( + + + + )] + fn length ( + + + self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Computes the squared length of `self`. + + /// + + ///This is faster than `length()` as it avoids a square root operation. + + #[lua( + + + + )] + fn length_squared ( + + + self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Computes `1.0 / length()`. + + /// + + ///For valid results, `self` must _not_ be of length zero. + + #[lua( + + + + )] + fn length_recip ( + + + self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Computes the Euclidean distance between two points in space. + + #[lua( + + + + )] + fn distance ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Compute the squared euclidean distance between two points in space. + + #[lua( + + + + )] + fn distance_squared ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns `self` normalized to length 1.0. + + /// + + ///For valid results, `self` must _not_ be of length zero, nor very close to zero. + + /// + + ///See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. + + /// + + ///Panics + + /// + + ///Will panic if `self` is zero length when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn normalize ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns `self` normalized to length 1.0 if possible, else returns zero. + + /// + + ///In particular, if the input is zero (or very close to zero), or non-finite, + + ///the result of this operation will be zero. + + /// + + ///See also [`Self::try_normalize()`]. + + #[lua( + + + + output(proxy), + + )] + fn normalize_or_zero ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns whether `self` is length `1.0` or not. + + /// + + ///Uses a precision threshold of `1e-6`. + + #[lua( + + + + )] + fn is_normalized ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns the vector projection of `self` onto `rhs`. + + /// + + ///`rhs` must be of non-zero length. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` is zero length when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn project_onto ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the vector rejection of `self` from `rhs`. + + /// + + ///The vector rejection is the vector perpendicular to the projection of `self` onto + + ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. + + /// + + ///`rhs` must be of non-zero length. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` has a length of zero when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn reject_from ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the vector projection of `self` onto `rhs`. + + /// + + ///`rhs` must be normalized. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn project_onto_normalized ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the vector rejection of `self` from `rhs`. + + /// + + ///The vector rejection is the vector perpendicular to the projection of `self` onto + + ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. + + /// + + ///`rhs` must be normalized. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn reject_from_normalized ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the nearest integer to a number for each element of `self`. + + ///Round half-way cases away from 0.0. + + #[lua( + + + + output(proxy), + + )] + fn round ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the largest integer less than or equal to a number for each + + ///element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn floor ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the smallest integer greater than or equal to a number for + + ///each element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn ceil ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the integer part each element of `self`. This means numbers are + + ///always truncated towards zero. + + #[lua( + + + + output(proxy), + + )] + fn trunc ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the fractional part of the vector, e.g. `self - + + ///self.floor()`. + + /// + + ///Note that this is fast but not precise for large numbers. + + #[lua( + + + + output(proxy), + + )] + fn fract ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing `e^self` (the exponential function) for each element of + + ///`self`. + + #[lua( + + + + output(proxy), + + )] + fn exp ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing each element of `self` raised to the power of `n`. + + #[lua( + + + + output(proxy), + + )] + fn powf ( + + + self, + + + + + n : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the reciprocal `1.0/n` of each element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn recip ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Performs a linear interpolation between `self` and `rhs` based on the value `s`. + + /// + + ///When `s` is `0.0`, the result will be equal to `self`. When `s` is `1.0`, the result + + ///will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly + + ///extrapolated. + + #[lua( + + + + output(proxy), + + )] + fn lerp ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + + + s : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns true if the absolute difference of all elements between `self` and `rhs` is + + ///less than or equal to `max_abs_diff`. + + /// + + ///This can be used to compare if two vectors contain similar elements. It works best when + + ///comparing with a known value. The `max_abs_diff` that should be used used depends on + + ///the values being compared against. + + /// + + ///For more see + + ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua( + + + + )] + fn abs_diff_eq ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + + + max_abs_diff : f32, + + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns a vector with a length no less than `min` and no more than `max` + + /// + + ///# Panics + + /// + + ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn clamp_length ( + + + self, + + + + + min : f32, + + + + + + max : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with a length no more than `max` + + #[lua( + + + + output(proxy), + + )] + fn clamp_length_max ( + + + self, + + + + + max : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with a length no less than `min` + + #[lua( + + + + output(proxy), + + )] + fn clamp_length_min ( + + + self, + + + + + min : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding + + ///error, yielding a more accurate result than an unfused multiply-add. + + /// + + ///Using `mul_add` *may* be more performant than an unfused multiply-add if the target + + ///architecture has a dedicated fma CPU instruction. However, this is not always true, + + ///and will be heavily dependant on designing algorithms with specific target hardware in + + ///mind. + + #[lua( + + + + output(proxy), + + )] + fn mul_add ( + + + self, + + + + + #[proxy] + + a : Self, + + + + + + #[proxy] + + b : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the angle (in radians) between two vectors. + + /// + + ///The inputs do not need to be unit vectors however they must be non-zero. + + #[lua( + + + + )] + fn angle_between ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns some vector that is orthogonal to the given one. + + /// + + ///The input vector must be finite and non-zero. + + /// + + ///The output vector is not necessarily unit length. For that use + + ///[`Self::any_orthonormal_vector()`] instead. + + #[lua( + + + + output(proxy), + + )] + fn any_orthogonal_vector ( + + + &self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns any unit vector that is orthogonal to the given one. + + /// + + ///The input vector must be unit length. + + /// + + ///# Panics + + /// + + ///Will panic if `self` is not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn any_orthonormal_vector ( + + + &self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Casts all elements of `self` to `f64`. + + #[lua( + + + + output(proxy), + + )] + fn as_dvec3 ( + + + &self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + ///Casts all elements of `self` to `i32`. + + #[lua( + + + + output(proxy), + + )] + fn as_ivec3 ( + + + &self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + ///Casts all elements of `self` to `u32`. + + #[lua( + + + + output(proxy), + + )] + fn as_uvec3 ( + + + &self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + ] +)] +pub struct Vec3A; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::f32::Vec4", + functions[r#" + + ///Creates a new vector. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn new ( + + + + x : f32, + + + + + + y : f32, + + + + + + z : f32, + + + + + + w : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector with all elements set to `v`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn splat ( + + + + v : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use + + ///for each element of `self`. + + /// + + ///A true element in the mask uses the corresponding element from `if_true`, and false + + ///uses the element from `if_false`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn select ( + + + + #[proxy] + + mask : bevy::math::bool::BVec4A, + + + + + + #[proxy] + + if_true : Self, + + + + + + #[proxy] + + if_false : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 2D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. + + /// + + ///Truncation to [`Vec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. + + /// + + ///To truncate to [`Vec3A`] use [`Vec3A::from()`]. + + #[lua( + + + + output(proxy), + + )] + fn truncate ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Computes the dot product of `self` and `rhs`. + + #[lua( + + + + )] + fn dot ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua( + + + + output(proxy), + + )] + fn dot_into_vec ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the minimum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn min ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the maximum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn max ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Component-wise clamping of values, similar to [`f32::clamp`]. + + /// + + ///Each element in `min` must be less-or-equal to the corresponding element in `max`. + + /// + + ///# Panics + + /// + + ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn clamp ( + + + self, + + + + + #[proxy] + + min : Self, + + + + + + #[proxy] + + max : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the horizontal minimum of `self`. + + /// + + ///In other words this computes `min(x, y, ..)`. + + #[lua( + + + + )] + fn min_element ( + + + self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns the horizontal maximum of `self`. + + /// + + ///In other words this computes `max(x, y, ..)`. + + #[lua( + + + + )] + fn max_element ( + + + self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `==` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpeq ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec4A + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `!=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpne ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec4A + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpge ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec4A + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpgt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec4A + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmple ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec4A + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmplt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec4A + + ; +"#, + r#" + + ///Returns a vector containing the absolute value of each element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn abs ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with elements representing the sign of `self`. + + /// + + ///- `1.0` if the number is positive, `+0.0` or `INFINITY` + + ///- `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` + + ///- `NAN` if the number is `NAN` + + #[lua( + + + + output(proxy), + + )] + fn signum ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with signs of `rhs` and the magnitudes of `self`. + + #[lua( + + + + output(proxy), + + )] + fn copysign ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a bitmask with the lowest 4 bits set to the sign bits from the elements of `self`. + + /// + + ///A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes + + ///into the first lowest bit, element `y` into the second, etc. + + #[lua( + + + + )] + fn is_negative_bitmask ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Returns `true` if, and only if, all elements are finite. If any element is either + + ///`NaN`, positive or negative infinity, this will return `false`. + + #[lua( + + + + )] + fn is_finite ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns `true` if any elements are `NaN`. + + #[lua( + + + + )] + fn is_nan ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Performs `is_nan` on each element of self, returning a vector mask of the results. + + /// + + ///In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. + + #[lua( + + + + output(proxy), + + )] + fn is_nan_mask ( + + + self, + + + ) + + + -> bevy::math::bool::BVec4A + + ; +"#, + r#" + + ///Computes the length of `self`. + + #[lua( + + + + )] + fn length ( + + + self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Computes the squared length of `self`. + + /// + + ///This is faster than `length()` as it avoids a square root operation. + + #[lua( + + + + )] + fn length_squared ( + + + self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Computes `1.0 / length()`. + + /// + + ///For valid results, `self` must _not_ be of length zero. + + #[lua( + + + + )] + fn length_recip ( + + + self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Computes the Euclidean distance between two points in space. + + #[lua( + + + + )] + fn distance ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Compute the squared euclidean distance between two points in space. + + #[lua( + + + + )] + fn distance_squared ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns `self` normalized to length 1.0. + + /// + + ///For valid results, `self` must _not_ be of length zero, nor very close to zero. + + /// + + ///See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. + + /// + + ///Panics + + /// + + ///Will panic if `self` is zero length when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn normalize ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns `self` normalized to length 1.0 if possible, else returns zero. + + /// + + ///In particular, if the input is zero (or very close to zero), or non-finite, + + ///the result of this operation will be zero. + + /// + + ///See also [`Self::try_normalize()`]. + + #[lua( + + + + output(proxy), + + )] + fn normalize_or_zero ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns whether `self` is length `1.0` or not. + + /// + + ///Uses a precision threshold of `1e-6`. + + #[lua( + + + + )] + fn is_normalized ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns the vector projection of `self` onto `rhs`. + + /// + + ///`rhs` must be of non-zero length. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` is zero length when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn project_onto ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the vector rejection of `self` from `rhs`. + + /// + + ///The vector rejection is the vector perpendicular to the projection of `self` onto + + ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. + + /// + + ///`rhs` must be of non-zero length. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` has a length of zero when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn reject_from ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the vector projection of `self` onto `rhs`. + + /// + + ///`rhs` must be normalized. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn project_onto_normalized ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the vector rejection of `self` from `rhs`. + + /// + + ///The vector rejection is the vector perpendicular to the projection of `self` onto + + ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. + + /// + + ///`rhs` must be normalized. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn reject_from_normalized ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the nearest integer to a number for each element of `self`. + + ///Round half-way cases away from 0.0. + + #[lua( + + + + output(proxy), + + )] + fn round ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the largest integer less than or equal to a number for each + + ///element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn floor ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the smallest integer greater than or equal to a number for + + ///each element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn ceil ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the integer part each element of `self`. This means numbers are + + ///always truncated towards zero. + + #[lua( + + + + output(proxy), + + )] + fn trunc ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the fractional part of the vector, e.g. `self - + + ///self.floor()`. + + /// + + ///Note that this is fast but not precise for large numbers. + + #[lua( + + + + output(proxy), + + )] + fn fract ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing `e^self` (the exponential function) for each element of + + ///`self`. + + #[lua( + + + + output(proxy), + + )] + fn exp ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing each element of `self` raised to the power of `n`. + + #[lua( + + + + output(proxy), + + )] + fn powf ( + + + self, + + + + + n : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the reciprocal `1.0/n` of each element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn recip ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Performs a linear interpolation between `self` and `rhs` based on the value `s`. + + /// + + ///When `s` is `0.0`, the result will be equal to `self`. When `s` is `1.0`, the result + + ///will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly + + ///extrapolated. + + #[lua( + + + + output(proxy), + + )] + fn lerp ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + + + s : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns true if the absolute difference of all elements between `self` and `rhs` is + + ///less than or equal to `max_abs_diff`. + + /// + + ///This can be used to compare if two vectors contain similar elements. It works best when + + ///comparing with a known value. The `max_abs_diff` that should be used used depends on + + ///the values being compared against. + + /// + + ///For more see + + ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua( + + + + )] + fn abs_diff_eq ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + + + max_abs_diff : f32, + + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns a vector with a length no less than `min` and no more than `max` + + /// + + ///# Panics + + /// + + ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn clamp_length ( + + + self, + + + + + min : f32, + + + + + + max : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with a length no more than `max` + + #[lua( + + + + output(proxy), + + )] + fn clamp_length_max ( + + + self, + + + + + max : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with a length no less than `min` + + #[lua( + + + + output(proxy), + + )] + fn clamp_length_min ( + + + self, + + + + + min : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding + + ///error, yielding a more accurate result than an unfused multiply-add. + + /// + + ///Using `mul_add` *may* be more performant than an unfused multiply-add if the target + + ///architecture has a dedicated fma CPU instruction. However, this is not always true, + + ///and will be heavily dependant on designing algorithms with specific target hardware in + + ///mind. + + #[lua( + + + + output(proxy), + + )] + fn mul_add ( + + + self, + + + + + #[proxy] + + a : Self, + + + + + + #[proxy] + + b : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Casts all elements of `self` to `f64`. + + #[lua( + + + + output(proxy), + + )] + fn as_dvec4 ( + + + &self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + ///Casts all elements of `self` to `i32`. + + #[lua( + + + + output(proxy), + + )] + fn as_ivec4 ( + + + &self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + ///Casts all elements of `self` to `u32`. + + #[lua( + + + + output(proxy), + + )] + fn as_uvec4 ( + + + &self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ww ( + + + self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xww ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yww ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zww ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn www ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxxw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxyw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxzw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxwx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxwy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxwz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxww ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyxw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyyw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyzw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xywx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xywy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xywz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyww ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzxw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzyw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzzw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzwx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzwy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzwz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzww ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwxw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwyw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwzw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwwx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwwy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwwz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwww ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxxw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxyw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxzw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxwx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxwy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxwz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxww ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyxw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyyw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyzw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yywx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yywy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yywz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyww ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzxw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzyw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzzw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzwx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzwy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzwz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzww ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywxw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywyw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywzw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywwx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywwy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywwz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywww ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxxw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxyw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxzw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxwx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxwy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxwz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxww ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyxw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyyw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyzw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zywx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zywy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zywz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyww ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzxw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzyw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzzw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzwx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzwy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzwz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzww ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwxw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwyw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwzw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwwx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwwy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwwz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwww ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxxw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxyw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxzw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxwx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxwy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxwz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxww ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyxw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyyw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyzw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wywx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wywy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wywz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyww ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzxw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzyw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzzw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzwx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzwy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzwz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzww ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwxx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwxy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwxz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwxw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwyx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwyy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwyw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwzx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwzy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwzz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwzw ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwwx ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwwy ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwwz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwww ( + + + self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + ] +)] +pub struct Vec4; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::bool::BVec2", + functions[r#" + + ///Creates a new vector mask. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn new ( + + + + x : bool, + + + + + + y : bool, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector with all elements set to `v`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn splat ( + + + + v : bool, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a bitmask with the lowest 2 bits set from the elements of `self`. + + /// + + ///A true element results in a `1` bit and a false element in a `0` bit. Element `x` goes + + ///into the first lowest bit, element `y` into the second, etc. + + #[lua( + + + + )] + fn bitmask ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Returns true if any of the elements are true, false otherwise. + + #[lua( + + + + )] + fn any ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns true if all the elements are true, false otherwise. + + #[lua( + + + + )] + fn all ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Tests the value at `index`. + + /// + + ///Panics if `index` is greater than 1. + + #[lua( + + + + )] + fn test ( + + + &self, + + + + + index : usize, + + + + ) + + + -> bool + + ; +"#, + r#" + + ///Sets the element at `index`. + + /// + + ///Panics if `index` is greater than 1. + + #[lua( + + + + )] + fn set ( + + + &mut self, + + + + + index : usize, + + + + + + value : bool, + + + + ) + ; +"#, + ] +)] +pub struct BVec2; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::bool::BVec3", + functions[r#" + + ///Creates a new vector mask. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn new ( + + + + x : bool, + + + + + + y : bool, + + + + + + z : bool, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector with all elements set to `v`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn splat ( + + + + v : bool, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a bitmask with the lowest 3 bits set from the elements of `self`. + + /// + + ///A true element results in a `1` bit and a false element in a `0` bit. Element `x` goes + + ///into the first lowest bit, element `y` into the second, etc. + + #[lua( + + + + )] + fn bitmask ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Returns true if any of the elements are true, false otherwise. + + #[lua( + + + + )] + fn any ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns true if all the elements are true, false otherwise. + + #[lua( + + + + )] + fn all ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Tests the value at `index`. + + /// + + ///Panics if `index` is greater than 2. + + #[lua( + + + + )] + fn test ( + + + &self, + + + + + index : usize, + + + + ) + + + -> bool + + ; +"#, + r#" + + ///Sets the element at `index`. + + /// + + ///Panics if `index` is greater than 2. + + #[lua( + + + + )] + fn set ( + + + &mut self, + + + + + index : usize, + + + + + + value : bool, + + + + ) + ; +"#, + ] +)] +pub struct BVec3; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::bool::BVec4", + functions[r#" + + ///Creates a new vector mask. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn new ( + + + + x : bool, + + + + + + y : bool, + + + + + + z : bool, + + + + + + w : bool, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector with all elements set to `v`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn splat ( + + + + v : bool, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a bitmask with the lowest 4 bits set from the elements of `self`. + + /// + + ///A true element results in a `1` bit and a false element in a `0` bit. Element `x` goes + + ///into the first lowest bit, element `y` into the second, etc. + + #[lua( + + + + )] + fn bitmask ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Returns true if any of the elements are true, false otherwise. + + #[lua( + + + + )] + fn any ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns true if all the elements are true, false otherwise. + + #[lua( + + + + )] + fn all ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Tests the value at `index`. + + /// + + ///Panics if `index` is greater than 3. + + #[lua( + + + + )] + fn test ( + + + &self, + + + + + index : usize, + + + + ) + + + -> bool + + ; +"#, + r#" + + ///Sets the element at `index`. + + /// + + ///Panics if `index` is greater than 3. + + #[lua( + + + + )] + fn set ( + + + &mut self, + + + + + index : usize, + + + + + + value : bool, + + + + ) + ; +"#, + ] +)] +pub struct BVec4; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::bool::BVec3A", + functions[r#" + + ///Creates a new vector mask. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn new ( + + + + x : bool, + + + + + + y : bool, + + + + + + z : bool, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector with all elements set to `v`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn splat ( + + + + v : bool, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a bitmask with the lowest 3 bits set from the elements of `self`. + + /// + + ///A true element results in a `1` bit and a false element in a `0` bit. Element `x` goes + + ///into the first lowest bit, element `y` into the second, etc. + + #[lua( + + + + )] + fn bitmask ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Returns true if any of the elements are true, false otherwise. + + #[lua( + + + + )] + fn any ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns true if all the elements are true, false otherwise. + + #[lua( + + + + )] + fn all ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Tests the value at `index`. + + /// + + ///Panics if `index` is greater than 2. + + #[lua( + + + + )] + fn test ( + + + &self, + + + + + index : usize, + + + + ) + + + -> bool + + ; +"#, + r#" + + ///Sets the element at `index`. + + /// + + ///Panics if `index` is greater than 2. + + #[lua( + + + + )] + fn set ( + + + &mut self, + + + + + index : usize, + + + + + + value : bool, + + + + ) + ; +"#, + ] +)] +pub struct BVec3A; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::bool::BVec4A", + functions[r#" + + ///Creates a new vector mask. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn new ( + + + + x : bool, + + + + + + y : bool, + + + + + + z : bool, + + + + + + w : bool, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector with all elements set to `v`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn splat ( + + + + v : bool, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a bitmask with the lowest 4 bits set from the elements of `self`. + + /// + + ///A true element results in a `1` bit and a false element in a `0` bit. Element `x` goes + + ///into the first lowest bit, element `y` into the second, etc. + + #[lua( + + + + )] + fn bitmask ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Returns true if any of the elements are true, false otherwise. + + #[lua( + + + + )] + fn any ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns true if all the elements are true, false otherwise. + + #[lua( + + + + )] + fn all ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Tests the value at `index`. + + /// + + ///Panics if `index` is greater than 3. + + #[lua( + + + + )] + fn test ( + + + &self, + + + + + index : usize, + + + + ) + + + -> bool + + ; +"#, + r#" + + ///Sets the element at `index`. + + /// + + ///Panics if `index` is greater than 3. + + #[lua( + + + + )] + fn set ( + + + &mut self, + + + + + index : usize, + + + + + + value : bool, + + + + ) + ; +"#, + ] +)] +pub struct BVec4A; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::f64::DVec2", + functions[r#" + + ///Creates a new vector. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn new ( + + + + x : f64, + + + + + + y : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector with all elements set to `v`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn splat ( + + + + v : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use + + ///for each element of `self`. + + /// + + ///A true element in the mask uses the corresponding element from `if_true`, and false + + ///uses the element from `if_false`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn select ( + + + + #[proxy] + + mask : bevy::math::bool::BVec2, + + + + + + #[proxy] + + if_true : Self, + + + + + + #[proxy] + + if_false : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3D vector from `self` and the given `z` value. + + #[lua( + + + + output(proxy), + + )] + fn extend ( + + + self, + + + + + z : f64, + + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + ///Computes the dot product of `self` and `rhs`. + + #[lua( + + + + )] + fn dot ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua( + + + + output(proxy), + + )] + fn dot_into_vec ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the minimum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn min ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the maximum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn max ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Component-wise clamping of values, similar to [`f64::clamp`]. + + /// + + ///Each element in `min` must be less-or-equal to the corresponding element in `max`. + + /// + + ///# Panics + + /// + + ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn clamp ( + + + self, + + + + + #[proxy] + + min : Self, + + + + + + #[proxy] + + max : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the horizontal minimum of `self`. + + /// + + ///In other words this computes `min(x, y, ..)`. + + #[lua( + + + + )] + fn min_element ( + + + self, + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Returns the horizontal maximum of `self`. + + /// + + ///In other words this computes `max(x, y, ..)`. + + #[lua( + + + + )] + fn max_element ( + + + self, + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `==` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpeq ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `!=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpne ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpge ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpgt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmple ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmplt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Returns a vector containing the absolute value of each element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn abs ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with elements representing the sign of `self`. + + /// + + ///- `1.0` if the number is positive, `+0.0` or `INFINITY` + + ///- `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` + + ///- `NAN` if the number is `NAN` + + #[lua( + + + + output(proxy), + + )] + fn signum ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with signs of `rhs` and the magnitudes of `self`. + + #[lua( + + + + output(proxy), + + )] + fn copysign ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a bitmask with the lowest 2 bits set to the sign bits from the elements of `self`. + + /// + + ///A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes + + ///into the first lowest bit, element `y` into the second, etc. + + #[lua( + + + + )] + fn is_negative_bitmask ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Returns `true` if, and only if, all elements are finite. If any element is either + + ///`NaN`, positive or negative infinity, this will return `false`. + + #[lua( + + + + )] + fn is_finite ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns `true` if any elements are `NaN`. + + #[lua( + + + + )] + fn is_nan ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Performs `is_nan` on each element of self, returning a vector mask of the results. + + /// + + ///In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. + + #[lua( + + + + output(proxy), + + )] + fn is_nan_mask ( + + + self, + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Computes the length of `self`. + + #[lua( + + + + )] + fn length ( + + + self, + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Computes the squared length of `self`. + + /// + + ///This is faster than `length()` as it avoids a square root operation. + + #[lua( + + + + )] + fn length_squared ( + + + self, + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Computes `1.0 / length()`. + + /// + + ///For valid results, `self` must _not_ be of length zero. + + #[lua( + + + + )] + fn length_recip ( + + + self, + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Computes the Euclidean distance between two points in space. + + #[lua( + + + + )] + fn distance ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Compute the squared euclidean distance between two points in space. + + #[lua( + + + + )] + fn distance_squared ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Returns `self` normalized to length 1.0. + + /// + + ///For valid results, `self` must _not_ be of length zero, nor very close to zero. + + /// + + ///See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. + + /// + + ///Panics + + /// + + ///Will panic if `self` is zero length when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn normalize ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns `self` normalized to length 1.0 if possible, else returns zero. + + /// + + ///In particular, if the input is zero (or very close to zero), or non-finite, + + ///the result of this operation will be zero. + + /// + + ///See also [`Self::try_normalize()`]. + + #[lua( + + + + output(proxy), + + )] + fn normalize_or_zero ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns whether `self` is length `1.0` or not. + + /// + + ///Uses a precision threshold of `1e-6`. + + #[lua( + + + + )] + fn is_normalized ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns the vector projection of `self` onto `rhs`. + + /// + + ///`rhs` must be of non-zero length. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` is zero length when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn project_onto ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the vector rejection of `self` from `rhs`. + + /// + + ///The vector rejection is the vector perpendicular to the projection of `self` onto + + ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. + + /// + + ///`rhs` must be of non-zero length. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` has a length of zero when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn reject_from ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the vector projection of `self` onto `rhs`. + + /// + + ///`rhs` must be normalized. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn project_onto_normalized ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the vector rejection of `self` from `rhs`. + + /// + + ///The vector rejection is the vector perpendicular to the projection of `self` onto + + ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. + + /// + + ///`rhs` must be normalized. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn reject_from_normalized ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the nearest integer to a number for each element of `self`. + + ///Round half-way cases away from 0.0. + + #[lua( + + + + output(proxy), + + )] + fn round ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the largest integer less than or equal to a number for each + + ///element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn floor ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the smallest integer greater than or equal to a number for + + ///each element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn ceil ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the integer part each element of `self`. This means numbers are + + ///always truncated towards zero. + + #[lua( + + + + output(proxy), + + )] + fn trunc ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the fractional part of the vector, e.g. `self - + + ///self.floor()`. + + /// + + ///Note that this is fast but not precise for large numbers. + + #[lua( + + + + output(proxy), + + )] + fn fract ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing `e^self` (the exponential function) for each element of + + ///`self`. + + #[lua( + + + + output(proxy), + + )] + fn exp ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing each element of `self` raised to the power of `n`. + + #[lua( + + + + output(proxy), + + )] + fn powf ( + + + self, + + + + + n : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the reciprocal `1.0/n` of each element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn recip ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Performs a linear interpolation between `self` and `rhs` based on the value `s`. + + /// + + ///When `s` is `0.0`, the result will be equal to `self`. When `s` is `1.0`, the result + + ///will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly + + ///extrapolated. + + #[lua( + + + + output(proxy), + + )] + fn lerp ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + + + s : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns true if the absolute difference of all elements between `self` and `rhs` is + + ///less than or equal to `max_abs_diff`. + + /// + + ///This can be used to compare if two vectors contain similar elements. It works best when + + ///comparing with a known value. The `max_abs_diff` that should be used used depends on + + ///the values being compared against. + + /// + + ///For more see + + ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua( + + + + )] + fn abs_diff_eq ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + + + max_abs_diff : f64, + + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns a vector with a length no less than `min` and no more than `max` + + /// + + ///# Panics + + /// + + ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn clamp_length ( + + + self, + + + + + min : f64, + + + + + + max : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with a length no more than `max` + + #[lua( + + + + output(proxy), + + )] + fn clamp_length_max ( + + + self, + + + + + max : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with a length no less than `min` + + #[lua( + + + + output(proxy), + + )] + fn clamp_length_min ( + + + self, + + + + + min : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding + + ///error, yielding a more accurate result than an unfused multiply-add. + + /// + + ///Using `mul_add` *may* be more performant than an unfused multiply-add if the target + + ///architecture has a dedicated fma CPU instruction. However, this is not always true, + + ///and will be heavily dependant on designing algorithms with specific target hardware in + + ///mind. + + #[lua( + + + + output(proxy), + + )] + fn mul_add ( + + + self, + + + + + #[proxy] + + a : Self, + + + + + + #[proxy] + + b : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 2D vector containing `[angle.cos(), angle.sin()]`. This can be used in + + ///conjunction with the [`rotate()`][Self::rotate()] method, e.g. + + ///`DVec2::from_angle(PI).rotate(DVec2::Y)` will create the vector `[-1, 0]` + + ///and rotate [`DVec2::Y`] around it returning `-DVec2::Y`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_angle ( + + + + angle : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the angle (in radians) between `self` and `rhs` in the range `[-π, +π]`. + + /// + + ///The inputs do not need to be unit vectors however they must be non-zero. + + #[lua( + + + + )] + fn angle_between ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Returns a vector that is equal to `self` rotated by 90 degrees. + + #[lua( + + + + output(proxy), + + )] + fn perp ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///The perpendicular dot product of `self` and `rhs`. + + ///Also known as the wedge product, 2D cross product, and determinant. + + #[lua( + + + + )] + fn perp_dot ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Returns `rhs` rotated by the angle of `self`. If `self` is normalized, + + ///then this just rotation. This is what you usually want. Otherwise, + + ///it will be like a rotation with a multiplication by `self`'s length. + + #[lua( + + + + output(proxy), + + )] + fn rotate ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Casts all elements of `self` to `f32`. + + #[lua( + + + + output(proxy), + + )] + fn as_vec2 ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + ///Casts all elements of `self` to `i32`. + + #[lua( + + + + output(proxy), + + )] + fn as_ivec2 ( + + + &self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + ///Casts all elements of `self` to `u32`. + + #[lua( + + + + output(proxy), + + )] + fn as_uvec2 ( + + + &self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xxxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xxxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xxyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xxyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xyxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xyxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xyyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xyyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yxxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yxxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yxyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yxyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yyxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yyxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yyyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yyyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + ] +)] +pub struct DVec2; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::f64::DVec3", + functions[r#" + + ///Creates a new vector. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn new ( + + + + x : f64, + + + + + + y : f64, + + + + + + z : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector with all elements set to `v`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn splat ( + + + + v : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use + + ///for each element of `self`. + + /// + + ///A true element in the mask uses the corresponding element from `if_true`, and false + + ///uses the element from `if_false`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn select ( + + + + #[proxy] + + mask : bevy::math::bool::BVec3, + + + + + + #[proxy] + + if_true : Self, + + + + + + #[proxy] + + if_false : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 4D vector from `self` and the given `w` value. + + #[lua( + + + + output(proxy), + + )] + fn extend ( + + + self, + + + + + w : f64, + + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + ///Creates a 2D vector from the `x` and `y` elements of `self`, discarding `z`. + + /// + + ///Truncation may also be performed by using [`self.xy()`][crate::swizzles::Vec3Swizzles::xy()]. + + #[lua( + + + + output(proxy), + + )] + fn truncate ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + ///Computes the dot product of `self` and `rhs`. + + #[lua( + + + + )] + fn dot ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua( + + + + output(proxy), + + )] + fn dot_into_vec ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Computes the cross product of `self` and `rhs`. + + #[lua( + + + + output(proxy), + + )] + fn cross ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the minimum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn min ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the maximum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn max ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Component-wise clamping of values, similar to [`f64::clamp`]. + + /// + + ///Each element in `min` must be less-or-equal to the corresponding element in `max`. + + /// + + ///# Panics + + /// + + ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn clamp ( + + + self, + + + + + #[proxy] + + min : Self, + + + + + + #[proxy] + + max : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the horizontal minimum of `self`. + + /// + + ///In other words this computes `min(x, y, ..)`. + + #[lua( + + + + )] + fn min_element ( + + + self, + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Returns the horizontal maximum of `self`. + + /// + + ///In other words this computes `max(x, y, ..)`. + + #[lua( + + + + )] + fn max_element ( + + + self, + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `==` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpeq ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `!=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpne ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpge ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpgt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmple ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmplt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Returns a vector containing the absolute value of each element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn abs ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with elements representing the sign of `self`. + + /// + + ///- `1.0` if the number is positive, `+0.0` or `INFINITY` + + ///- `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` + + ///- `NAN` if the number is `NAN` + + #[lua( + + + + output(proxy), + + )] + fn signum ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with signs of `rhs` and the magnitudes of `self`. + + #[lua( + + + + output(proxy), + + )] + fn copysign ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of `self`. + + /// + + ///A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes + + ///into the first lowest bit, element `y` into the second, etc. + + #[lua( + + + + )] + fn is_negative_bitmask ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Returns `true` if, and only if, all elements are finite. If any element is either + + ///`NaN`, positive or negative infinity, this will return `false`. + + #[lua( + + + + )] + fn is_finite ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns `true` if any elements are `NaN`. + + #[lua( + + + + )] + fn is_nan ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Performs `is_nan` on each element of self, returning a vector mask of the results. + + /// + + ///In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. + + #[lua( + + + + output(proxy), + + )] + fn is_nan_mask ( + + + self, + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Computes the length of `self`. + + #[lua( + + + + )] + fn length ( + + + self, + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Computes the squared length of `self`. + + /// + + ///This is faster than `length()` as it avoids a square root operation. + + #[lua( + + + + )] + fn length_squared ( + + + self, + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Computes `1.0 / length()`. + + /// + + ///For valid results, `self` must _not_ be of length zero. + + #[lua( + + + + )] + fn length_recip ( + + + self, + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Computes the Euclidean distance between two points in space. + + #[lua( + + + + )] + fn distance ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Compute the squared euclidean distance between two points in space. + + #[lua( + + + + )] + fn distance_squared ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Returns `self` normalized to length 1.0. + + /// + + ///For valid results, `self` must _not_ be of length zero, nor very close to zero. + + /// + + ///See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. + + /// + + ///Panics + + /// + + ///Will panic if `self` is zero length when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn normalize ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns `self` normalized to length 1.0 if possible, else returns zero. + + /// + + ///In particular, if the input is zero (or very close to zero), or non-finite, + + ///the result of this operation will be zero. + + /// + + ///See also [`Self::try_normalize()`]. + + #[lua( + + + + output(proxy), + + )] + fn normalize_or_zero ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns whether `self` is length `1.0` or not. + + /// + + ///Uses a precision threshold of `1e-6`. + + #[lua( + + + + )] + fn is_normalized ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns the vector projection of `self` onto `rhs`. + + /// + + ///`rhs` must be of non-zero length. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` is zero length when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn project_onto ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the vector rejection of `self` from `rhs`. + + /// + + ///The vector rejection is the vector perpendicular to the projection of `self` onto + + ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. + + /// + + ///`rhs` must be of non-zero length. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` has a length of zero when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn reject_from ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the vector projection of `self` onto `rhs`. + + /// + + ///`rhs` must be normalized. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn project_onto_normalized ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the vector rejection of `self` from `rhs`. + + /// + + ///The vector rejection is the vector perpendicular to the projection of `self` onto + + ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. + + /// + + ///`rhs` must be normalized. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn reject_from_normalized ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the nearest integer to a number for each element of `self`. + + ///Round half-way cases away from 0.0. + + #[lua( + + + + output(proxy), + + )] + fn round ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the largest integer less than or equal to a number for each + + ///element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn floor ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the smallest integer greater than or equal to a number for + + ///each element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn ceil ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the integer part each element of `self`. This means numbers are + + ///always truncated towards zero. + + #[lua( + + + + output(proxy), + + )] + fn trunc ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the fractional part of the vector, e.g. `self - + + ///self.floor()`. + + /// + + ///Note that this is fast but not precise for large numbers. + + #[lua( + + + + output(proxy), + + )] + fn fract ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing `e^self` (the exponential function) for each element of + + ///`self`. + + #[lua( + + + + output(proxy), + + )] + fn exp ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing each element of `self` raised to the power of `n`. + + #[lua( + + + + output(proxy), + + )] + fn powf ( + + + self, + + + + + n : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the reciprocal `1.0/n` of each element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn recip ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Performs a linear interpolation between `self` and `rhs` based on the value `s`. + + /// + + ///When `s` is `0.0`, the result will be equal to `self`. When `s` is `1.0`, the result + + ///will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly + + ///extrapolated. + + #[lua( + + + + output(proxy), + + )] + fn lerp ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + + + s : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns true if the absolute difference of all elements between `self` and `rhs` is + + ///less than or equal to `max_abs_diff`. + + /// + + ///This can be used to compare if two vectors contain similar elements. It works best when + + ///comparing with a known value. The `max_abs_diff` that should be used used depends on + + ///the values being compared against. + + /// + + ///For more see + + ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua( + + + + )] + fn abs_diff_eq ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + + + max_abs_diff : f64, + + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns a vector with a length no less than `min` and no more than `max` + + /// + + ///# Panics + + /// + + ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn clamp_length ( + + + self, + + + + + min : f64, + + + + + + max : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with a length no more than `max` + + #[lua( + + + + output(proxy), + + )] + fn clamp_length_max ( + + + self, + + + + + max : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with a length no less than `min` + + #[lua( + + + + output(proxy), + + )] + fn clamp_length_min ( + + + self, + + + + + min : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding + + ///error, yielding a more accurate result than an unfused multiply-add. + + /// + + ///Using `mul_add` *may* be more performant than an unfused multiply-add if the target + + ///architecture has a dedicated fma CPU instruction. However, this is not always true, + + ///and will be heavily dependant on designing algorithms with specific target hardware in + + ///mind. + + #[lua( + + + + output(proxy), + + )] + fn mul_add ( + + + self, + + + + + #[proxy] + + a : Self, + + + + + + #[proxy] + + b : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the angle (in radians) between two vectors. + + /// + + ///The inputs do not need to be unit vectors however they must be non-zero. + + #[lua( + + + + )] + fn angle_between ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Returns some vector that is orthogonal to the given one. + + /// + + ///The input vector must be finite and non-zero. + + /// + + ///The output vector is not necessarily unit length. For that use + + ///[`Self::any_orthonormal_vector()`] instead. + + #[lua( + + + + output(proxy), + + )] + fn any_orthogonal_vector ( + + + &self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns any unit vector that is orthogonal to the given one. + + /// + + ///The input vector must be unit length. + + /// + + ///# Panics + + /// + + ///Will panic if `self` is not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn any_orthonormal_vector ( + + + &self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Casts all elements of `self` to `f32`. + + #[lua( + + + + output(proxy), + + )] + fn as_vec3 ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Casts all elements of `self` to `f32`. + + #[lua( + + + + output(proxy), + + )] + fn as_vec3a ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + ///Casts all elements of `self` to `i32`. + + #[lua( + + + + output(proxy), + + )] + fn as_ivec3 ( + + + &self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + ///Casts all elements of `self` to `u32`. + + #[lua( + + + + output(proxy), + + )] + fn as_uvec3 ( + + + &self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + ] +)] +pub struct DVec3; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::f64::DVec4", + functions[r#" + + ///Creates a new vector. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn new ( + + + + x : f64, + + + + + + y : f64, + + + + + + z : f64, + + + + + + w : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector with all elements set to `v`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn splat ( + + + + v : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use + + ///for each element of `self`. + + /// + + ///A true element in the mask uses the corresponding element from `if_true`, and false + + ///uses the element from `if_false`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn select ( + + + + #[proxy] + + mask : bevy::math::bool::BVec4, + + + + + + #[proxy] + + if_true : Self, + + + + + + #[proxy] + + if_false : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 2D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. + + /// + + ///Truncation to [`DVec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. + + #[lua( + + + + output(proxy), + + )] + fn truncate ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + ///Computes the dot product of `self` and `rhs`. + + #[lua( + + + + )] + fn dot ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua( + + + + output(proxy), + + )] + fn dot_into_vec ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the minimum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn min ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the maximum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn max ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Component-wise clamping of values, similar to [`f64::clamp`]. + + /// + + ///Each element in `min` must be less-or-equal to the corresponding element in `max`. + + /// + + ///# Panics + + /// + + ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn clamp ( + + + self, + + + + + #[proxy] + + min : Self, + + + + + + #[proxy] + + max : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the horizontal minimum of `self`. + + /// + + ///In other words this computes `min(x, y, ..)`. + + #[lua( + + + + )] + fn min_element ( + + + self, + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Returns the horizontal maximum of `self`. + + /// + + ///In other words this computes `max(x, y, ..)`. + + #[lua( + + + + )] + fn max_element ( + + + self, + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `==` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpeq ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec4 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `!=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpne ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec4 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpge ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec4 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpgt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec4 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmple ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec4 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmplt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec4 + + ; +"#, + r#" + + ///Returns a vector containing the absolute value of each element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn abs ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with elements representing the sign of `self`. + + /// + + ///- `1.0` if the number is positive, `+0.0` or `INFINITY` + + ///- `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` + + ///- `NAN` if the number is `NAN` + + #[lua( + + + + output(proxy), + + )] + fn signum ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with signs of `rhs` and the magnitudes of `self`. + + #[lua( + + + + output(proxy), + + )] + fn copysign ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a bitmask with the lowest 4 bits set to the sign bits from the elements of `self`. + + /// + + ///A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes + + ///into the first lowest bit, element `y` into the second, etc. + + #[lua( + + + + )] + fn is_negative_bitmask ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Returns `true` if, and only if, all elements are finite. If any element is either + + ///`NaN`, positive or negative infinity, this will return `false`. + + #[lua( + + + + )] + fn is_finite ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns `true` if any elements are `NaN`. + + #[lua( + + + + )] + fn is_nan ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Performs `is_nan` on each element of self, returning a vector mask of the results. + + /// + + ///In other words, this computes `[x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]`. + + #[lua( + + + + output(proxy), + + )] + fn is_nan_mask ( + + + self, + + + ) + + + -> bevy::math::bool::BVec4 + + ; +"#, + r#" + + ///Computes the length of `self`. + + #[lua( + + + + )] + fn length ( + + + self, + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Computes the squared length of `self`. + + /// + + ///This is faster than `length()` as it avoids a square root operation. + + #[lua( + + + + )] + fn length_squared ( + + + self, + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Computes `1.0 / length()`. + + /// + + ///For valid results, `self` must _not_ be of length zero. + + #[lua( + + + + )] + fn length_recip ( + + + self, + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Computes the Euclidean distance between two points in space. + + #[lua( + + + + )] + fn distance ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Compute the squared euclidean distance between two points in space. + + #[lua( + + + + )] + fn distance_squared ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Returns `self` normalized to length 1.0. + + /// + + ///For valid results, `self` must _not_ be of length zero, nor very close to zero. + + /// + + ///See also [`Self::try_normalize()`] and [`Self::normalize_or_zero()`]. + + /// + + ///Panics + + /// + + ///Will panic if `self` is zero length when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn normalize ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns `self` normalized to length 1.0 if possible, else returns zero. + + /// + + ///In particular, if the input is zero (or very close to zero), or non-finite, + + ///the result of this operation will be zero. + + /// + + ///See also [`Self::try_normalize()`]. + + #[lua( + + + + output(proxy), + + )] + fn normalize_or_zero ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns whether `self` is length `1.0` or not. + + /// + + ///Uses a precision threshold of `1e-6`. + + #[lua( + + + + )] + fn is_normalized ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns the vector projection of `self` onto `rhs`. + + /// + + ///`rhs` must be of non-zero length. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` is zero length when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn project_onto ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the vector rejection of `self` from `rhs`. + + /// + + ///The vector rejection is the vector perpendicular to the projection of `self` onto + + ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. + + /// + + ///`rhs` must be of non-zero length. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` has a length of zero when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn reject_from ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the vector projection of `self` onto `rhs`. + + /// + + ///`rhs` must be normalized. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn project_onto_normalized ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the vector rejection of `self` from `rhs`. + + /// + + ///The vector rejection is the vector perpendicular to the projection of `self` onto + + ///`rhs`, in rhs words the result of `self - self.project_onto(rhs)`. + + /// + + ///`rhs` must be normalized. + + /// + + ///# Panics + + /// + + ///Will panic if `rhs` is not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn reject_from_normalized ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the nearest integer to a number for each element of `self`. + + ///Round half-way cases away from 0.0. + + #[lua( + + + + output(proxy), + + )] + fn round ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the largest integer less than or equal to a number for each + + ///element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn floor ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the smallest integer greater than or equal to a number for + + ///each element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn ceil ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the integer part each element of `self`. This means numbers are + + ///always truncated towards zero. + + #[lua( + + + + output(proxy), + + )] + fn trunc ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the fractional part of the vector, e.g. `self - + + ///self.floor()`. + + /// + + ///Note that this is fast but not precise for large numbers. + + #[lua( + + + + output(proxy), + + )] + fn fract ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing `e^self` (the exponential function) for each element of + + ///`self`. + + #[lua( + + + + output(proxy), + + )] + fn exp ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing each element of `self` raised to the power of `n`. + + #[lua( + + + + output(proxy), + + )] + fn powf ( + + + self, + + + + + n : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the reciprocal `1.0/n` of each element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn recip ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Performs a linear interpolation between `self` and `rhs` based on the value `s`. + + /// + + ///When `s` is `0.0`, the result will be equal to `self`. When `s` is `1.0`, the result + + ///will be equal to `rhs`. When `s` is outside of range `[0, 1]`, the result is linearly + + ///extrapolated. + + #[lua( + + + + output(proxy), + + )] + fn lerp ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + + + s : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns true if the absolute difference of all elements between `self` and `rhs` is + + ///less than or equal to `max_abs_diff`. + + /// + + ///This can be used to compare if two vectors contain similar elements. It works best when + + ///comparing with a known value. The `max_abs_diff` that should be used used depends on + + ///the values being compared against. + + /// + + ///For more see + + ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua( + + + + )] + fn abs_diff_eq ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + + + max_abs_diff : f64, + + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns a vector with a length no less than `min` and no more than `max` + + /// + + ///# Panics + + /// + + ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn clamp_length ( + + + self, + + + + + min : f64, + + + + + + max : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with a length no more than `max` + + #[lua( + + + + output(proxy), + + )] + fn clamp_length_max ( + + + self, + + + + + max : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with a length no less than `min` + + #[lua( + + + + output(proxy), + + )] + fn clamp_length_min ( + + + self, + + + + + min : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Fused multiply-add. Computes `(self * a) + b` element-wise with only one rounding + + ///error, yielding a more accurate result than an unfused multiply-add. + + /// + + ///Using `mul_add` *may* be more performant than an unfused multiply-add if the target + + ///architecture has a dedicated fma CPU instruction. However, this is not always true, + + ///and will be heavily dependant on designing algorithms with specific target hardware in + + ///mind. + + #[lua( + + + + output(proxy), + + )] + fn mul_add ( + + + self, + + + + + #[proxy] + + a : Self, + + + + + + #[proxy] + + b : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Casts all elements of `self` to `f32`. + + #[lua( + + + + output(proxy), + + )] + fn as_vec4 ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + ///Casts all elements of `self` to `i32`. + + #[lua( + + + + output(proxy), + + )] + fn as_ivec4 ( + + + &self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + ///Casts all elements of `self` to `u32`. + + #[lua( + + + + output(proxy), + + )] + fn as_uvec4 ( + + + &self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ww ( + + + self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xww ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yww ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zww ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn www ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxxw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxyw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxzw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxwx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxwy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxwz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxww ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyxw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyyw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyzw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xywx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xywy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xywz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyww ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzxw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzyw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzzw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzwx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzwy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzwz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzww ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwxw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwyw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwzw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwwx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwwy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwwz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwww ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxxw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxyw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxzw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxwx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxwy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxwz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxww ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyxw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyyw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyzw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yywx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yywy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yywz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyww ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzxw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzyw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzzw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzwx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzwy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzwz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzww ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywxw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywyw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywzw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywwx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywwy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywwz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywww ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxxw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxyw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxzw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxwx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxwy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxwz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxww ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyxw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyyw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyzw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zywx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zywy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zywz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyww ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzxw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzyw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzzw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzwx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzwy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzwz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzww ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwxw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwyw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwzw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwwx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwwy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwwz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwww ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxxw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxyw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxzw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxwx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxwy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxwz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxww ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyxw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyyw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyzw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wywx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wywy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wywz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyww ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzxw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzyw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzzw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzwx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzwy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzwz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzww ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwxx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwxy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwxz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwxw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwyx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwyy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwyw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwzx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwzy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwzz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwzw ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwwx ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwwy ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwwz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwww ( + + + self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + ] +)] +pub struct DVec4; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::i32::IVec2", + functions[r#" + + ///Creates a new vector. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn new ( + + + + x : i32, + + + + + + y : i32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector with all elements set to `v`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn splat ( + + + + v : i32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use + + ///for each element of `self`. + + /// + + ///A true element in the mask uses the corresponding element from `if_true`, and false + + ///uses the element from `if_false`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn select ( + + + + #[proxy] + + mask : bevy::math::bool::BVec2, + + + + + + #[proxy] + + if_true : Self, + + + + + + #[proxy] + + if_false : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3D vector from `self` and the given `z` value. + + #[lua( + + + + output(proxy), + + )] + fn extend ( + + + self, + + + + + z : i32, + + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + ///Computes the dot product of `self` and `rhs`. + + #[lua( + + + + )] + fn dot ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> i32 + + ; +"#, + r#" + + ///Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua( + + + + output(proxy), + + )] + fn dot_into_vec ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the minimum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn min ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the maximum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn max ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Component-wise clamping of values, similar to [`i32::clamp`]. + + /// + + ///Each element in `min` must be less-or-equal to the corresponding element in `max`. + + /// + + ///# Panics + + /// + + ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn clamp ( + + + self, + + + + + #[proxy] + + min : Self, + + + + + + #[proxy] + + max : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the horizontal minimum of `self`. + + /// + + ///In other words this computes `min(x, y, ..)`. + + #[lua( + + + + )] + fn min_element ( + + + self, + + + ) + + + -> i32 + + ; +"#, + r#" + + ///Returns the horizontal maximum of `self`. + + /// + + ///In other words this computes `max(x, y, ..)`. + + #[lua( + + + + )] + fn max_element ( + + + self, + + + ) + + + -> i32 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `==` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpeq ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `!=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpne ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpge ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpgt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmple ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmplt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Returns a vector containing the absolute value of each element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn abs ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with elements representing the sign of `self`. + + /// + + /// - `0` if the number is zero + + /// - `1` if the number is positive + + /// - `-1` if the number is negative + + #[lua( + + + + output(proxy), + + )] + fn signum ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a bitmask with the lowest 2 bits set to the sign bits from the elements of `self`. + + /// + + ///A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes + + ///into the first lowest bit, element `y` into the second, etc. + + #[lua( + + + + )] + fn is_negative_bitmask ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Computes the squared length of `self`. + + #[lua( + + + + )] + fn length_squared ( + + + self, + + + ) + + + -> i32 + + ; +"#, + r#" + + ///Compute the squared euclidean distance between two points in space. + + #[lua( + + + + )] + fn distance_squared ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> i32 + + ; +"#, + r#" + + ///Returns a vector that is equal to `self` rotated by 90 degrees. + + #[lua( + + + + output(proxy), + + )] + fn perp ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///The perpendicular dot product of `self` and `rhs`. + + ///Also known as the wedge product, 2D cross product, and determinant. + + #[lua( + + + + )] + fn perp_dot ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> i32 + + ; +"#, + r#" + + ///Returns `rhs` rotated by the angle of `self`. If `self` is normalized, + + ///then this just rotation. This is what you usually want. Otherwise, + + ///it will be like a rotation with a multiplication by `self`'s length. + + #[lua( + + + + output(proxy), + + )] + fn rotate ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Casts all elements of `self` to `f32`. + + #[lua( + + + + output(proxy), + + )] + fn as_vec2 ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + ///Casts all elements of `self` to `f64`. + + #[lua( + + + + output(proxy), + + )] + fn as_dvec2 ( + + + &self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + ///Casts all elements of `self` to `u32`. + + #[lua( + + + + output(proxy), + + )] + fn as_uvec2 ( + + + &self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xxxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xxxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xxyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xxyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xyxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xyxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xyyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xyyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yxxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yxxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yxyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yxyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yyxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yyxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yyyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yyyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + ] +)] +pub struct IVec2; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::i32::IVec3", + functions[r#" + + ///Creates a new vector. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn new ( + + + + x : i32, + + + + + + y : i32, + + + + + + z : i32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector with all elements set to `v`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn splat ( + + + + v : i32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use + + ///for each element of `self`. + + /// + + ///A true element in the mask uses the corresponding element from `if_true`, and false + + ///uses the element from `if_false`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn select ( + + + + #[proxy] + + mask : bevy::math::bool::BVec3, + + + + + + #[proxy] + + if_true : Self, + + + + + + #[proxy] + + if_false : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 4D vector from `self` and the given `w` value. + + #[lua( + + + + output(proxy), + + )] + fn extend ( + + + self, + + + + + w : i32, + + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + ///Creates a 2D vector from the `x` and `y` elements of `self`, discarding `z`. + + /// + + ///Truncation may also be performed by using [`self.xy()`][crate::swizzles::Vec3Swizzles::xy()]. + + #[lua( + + + + output(proxy), + + )] + fn truncate ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + ///Computes the dot product of `self` and `rhs`. + + #[lua( + + + + )] + fn dot ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> i32 + + ; +"#, + r#" + + ///Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua( + + + + output(proxy), + + )] + fn dot_into_vec ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Computes the cross product of `self` and `rhs`. + + #[lua( + + + + output(proxy), + + )] + fn cross ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the minimum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn min ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the maximum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn max ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Component-wise clamping of values, similar to [`i32::clamp`]. + + /// + + ///Each element in `min` must be less-or-equal to the corresponding element in `max`. + + /// + + ///# Panics + + /// + + ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn clamp ( + + + self, + + + + + #[proxy] + + min : Self, + + + + + + #[proxy] + + max : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the horizontal minimum of `self`. + + /// + + ///In other words this computes `min(x, y, ..)`. + + #[lua( + + + + )] + fn min_element ( + + + self, + + + ) + + + -> i32 + + ; +"#, + r#" + + ///Returns the horizontal maximum of `self`. + + /// + + ///In other words this computes `max(x, y, ..)`. + + #[lua( + + + + )] + fn max_element ( + + + self, + + + ) + + + -> i32 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `==` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpeq ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `!=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpne ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpge ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpgt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmple ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmplt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Returns a vector containing the absolute value of each element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn abs ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with elements representing the sign of `self`. + + /// + + /// - `0` if the number is zero + + /// - `1` if the number is positive + + /// - `-1` if the number is negative + + #[lua( + + + + output(proxy), + + )] + fn signum ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a bitmask with the lowest 3 bits set to the sign bits from the elements of `self`. + + /// + + ///A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes + + ///into the first lowest bit, element `y` into the second, etc. + + #[lua( + + + + )] + fn is_negative_bitmask ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Computes the squared length of `self`. + + #[lua( + + + + )] + fn length_squared ( + + + self, + + + ) + + + -> i32 + + ; +"#, + r#" + + ///Compute the squared euclidean distance between two points in space. + + #[lua( + + + + )] + fn distance_squared ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> i32 + + ; +"#, + r#" + + ///Casts all elements of `self` to `f32`. + + #[lua( + + + + output(proxy), + + )] + fn as_vec3 ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Casts all elements of `self` to `f32`. + + #[lua( + + + + output(proxy), + + )] + fn as_vec3a ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + ///Casts all elements of `self` to `f64`. + + #[lua( + + + + output(proxy), + + )] + fn as_dvec3 ( + + + &self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + ///Casts all elements of `self` to `u32`. + + #[lua( + + + + output(proxy), + + )] + fn as_uvec3 ( + + + &self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + ] +)] +pub struct IVec3; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::i32::IVec4", + functions[r#" + + ///Creates a new vector. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn new ( + + + + x : i32, + + + + + + y : i32, + + + + + + z : i32, + + + + + + w : i32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector with all elements set to `v`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn splat ( + + + + v : i32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use + + ///for each element of `self`. + + /// + + ///A true element in the mask uses the corresponding element from `if_true`, and false + + ///uses the element from `if_false`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn select ( + + + + #[proxy] + + mask : bevy::math::bool::BVec4, + + + + + + #[proxy] + + if_true : Self, + + + + + + #[proxy] + + if_false : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 2D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. + + /// + + ///Truncation to [`IVec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. + + #[lua( + + + + output(proxy), + + )] + fn truncate ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + ///Computes the dot product of `self` and `rhs`. + + #[lua( + + + + )] + fn dot ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> i32 + + ; +"#, + r#" + + ///Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua( + + + + output(proxy), + + )] + fn dot_into_vec ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the minimum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn min ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the maximum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn max ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Component-wise clamping of values, similar to [`i32::clamp`]. + + /// + + ///Each element in `min` must be less-or-equal to the corresponding element in `max`. + + /// + + ///# Panics + + /// + + ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn clamp ( + + + self, + + + + + #[proxy] + + min : Self, + + + + + + #[proxy] + + max : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the horizontal minimum of `self`. + + /// + + ///In other words this computes `min(x, y, ..)`. + + #[lua( + + + + )] + fn min_element ( + + + self, + + + ) + + + -> i32 + + ; +"#, + r#" + + ///Returns the horizontal maximum of `self`. + + /// + + ///In other words this computes `max(x, y, ..)`. + + #[lua( + + + + )] + fn max_element ( + + + self, + + + ) + + + -> i32 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `==` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpeq ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec4 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `!=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpne ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec4 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpge ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec4 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpgt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec4 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmple ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec4 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmplt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec4 + + ; +"#, + r#" + + ///Returns a vector containing the absolute value of each element of `self`. + + #[lua( + + + + output(proxy), + + )] + fn abs ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector with elements representing the sign of `self`. + + /// + + /// - `0` if the number is zero + + /// - `1` if the number is positive + + /// - `-1` if the number is negative + + #[lua( + + + + output(proxy), + + )] + fn signum ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a bitmask with the lowest 4 bits set to the sign bits from the elements of `self`. + + /// + + ///A negative element results in a `1` bit and a positive element in a `0` bit. Element `x` goes + + ///into the first lowest bit, element `y` into the second, etc. + + #[lua( + + + + )] + fn is_negative_bitmask ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Computes the squared length of `self`. + + #[lua( + + + + )] + fn length_squared ( + + + self, + + + ) + + + -> i32 + + ; +"#, + r#" + + ///Compute the squared euclidean distance between two points in space. + + #[lua( + + + + )] + fn distance_squared ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> i32 + + ; +"#, + r#" + + ///Casts all elements of `self` to `f32`. + + #[lua( + + + + output(proxy), + + )] + fn as_vec4 ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + ///Casts all elements of `self` to `f64`. + + #[lua( + + + + output(proxy), + + )] + fn as_dvec4 ( + + + &self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + ///Casts all elements of `self` to `u32`. + + #[lua( + + + + output(proxy), + + )] + fn as_uvec4 ( + + + &self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ww ( + + + self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xww ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yww ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zww ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn www ( + + + self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxxw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxyw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxzw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxwx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxwy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxwz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxww ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyxw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyyw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyzw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xywx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xywy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xywz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyww ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzxw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzyw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzzw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzwx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzwy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzwz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzww ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwxw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwyw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwzw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwwx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwwy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwwz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwww ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxxw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxyw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxzw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxwx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxwy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxwz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxww ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyxw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyyw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyzw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yywx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yywy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yywz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyww ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzxw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzyw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzzw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzwx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzwy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzwz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzww ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywxw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywyw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywzw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywwx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywwy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywwz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywww ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxxw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxyw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxzw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxwx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxwy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxwz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxww ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyxw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyyw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyzw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zywx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zywy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zywz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyww ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzxw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzyw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzzw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzwx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzwy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzwz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzww ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwxw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwyw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwzw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwwx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwwy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwwz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwww ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxxw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxyw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxzw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxwx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxwy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxwz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxww ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyxw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyyw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyzw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wywx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wywy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wywz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyww ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzxw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzyw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzzw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzwx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzwy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzwz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzww ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwxx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwxy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwxz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwxw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwyx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwyy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwyz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwyw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwzx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwzy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwzz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwzw ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwwx ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwwy ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwwz ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwww ( + + + self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + ] +)] +pub struct IVec4; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::u32::UVec2", + functions[r#" + + ///Creates a new vector. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn new ( + + + + x : u32, + + + + + + y : u32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector with all elements set to `v`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn splat ( + + + + v : u32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use + + ///for each element of `self`. + + /// + + ///A true element in the mask uses the corresponding element from `if_true`, and false + + ///uses the element from `if_false`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn select ( + + + + #[proxy] + + mask : bevy::math::bool::BVec2, + + + + + + #[proxy] + + if_true : Self, + + + + + + #[proxy] + + if_false : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3D vector from `self` and the given `z` value. + + #[lua( + + + + output(proxy), + + )] + fn extend ( + + + self, + + + + + z : u32, + + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + ///Computes the dot product of `self` and `rhs`. + + #[lua( + + + + )] + fn dot ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua( + + + + output(proxy), + + )] + fn dot_into_vec ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the minimum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn min ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the maximum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn max ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Component-wise clamping of values, similar to [`u32::clamp`]. + + /// + + ///Each element in `min` must be less-or-equal to the corresponding element in `max`. + + /// + + ///# Panics + + /// + + ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn clamp ( + + + self, + + + + + #[proxy] + + min : Self, + + + + + + #[proxy] + + max : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the horizontal minimum of `self`. + + /// + + ///In other words this computes `min(x, y, ..)`. + + #[lua( + + + + )] + fn min_element ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Returns the horizontal maximum of `self`. + + /// + + ///In other words this computes `max(x, y, ..)`. + + #[lua( + + + + )] + fn max_element ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `==` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpeq ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `!=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpne ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpge ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpgt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmple ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmplt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec2 + + ; +"#, + r#" + + ///Computes the squared length of `self`. + + #[lua( + + + + )] + fn length_squared ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Casts all elements of `self` to `f32`. + + #[lua( + + + + output(proxy), + + )] + fn as_vec2 ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + ///Casts all elements of `self` to `f64`. + + #[lua( + + + + output(proxy), + + )] + fn as_dvec2 ( + + + &self, + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + ///Casts all elements of `self` to `i32`. + + #[lua( + + + + output(proxy), + + )] + fn as_ivec2 ( + + + &self, + + + ) + + + -> bevy::math::i32::IVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xxxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xxxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xxyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xxyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xyxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xyxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xyyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn xyyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yxxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yxxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yxyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yxyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yyxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yyxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yyyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec2Swizzles", + + + output(proxy), + + )] + fn yyyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + ] +)] +pub struct UVec2; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::u32::UVec3", + functions[r#" + + ///Creates a new vector. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn new ( + + + + x : u32, + + + + + + y : u32, + + + + + + z : u32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector with all elements set to `v`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn splat ( + + + + v : u32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use + + ///for each element of `self`. + + /// + + ///A true element in the mask uses the corresponding element from `if_true`, and false + + ///uses the element from `if_false`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn select ( + + + + #[proxy] + + mask : bevy::math::bool::BVec3, + + + + + + #[proxy] + + if_true : Self, + + + + + + #[proxy] + + if_false : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 4D vector from `self` and the given `w` value. + + #[lua( + + + + output(proxy), + + )] + fn extend ( + + + self, + + + + + w : u32, + + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + ///Creates a 2D vector from the `x` and `y` elements of `self`, discarding `z`. + + /// + + ///Truncation may also be performed by using [`self.xy()`][crate::swizzles::Vec3Swizzles::xy()]. + + #[lua( + + + + output(proxy), + + )] + fn truncate ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + ///Computes the dot product of `self` and `rhs`. + + #[lua( + + + + )] + fn dot ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua( + + + + output(proxy), + + )] + fn dot_into_vec ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Computes the cross product of `self` and `rhs`. + + #[lua( + + + + output(proxy), + + )] + fn cross ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the minimum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn min ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the maximum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn max ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Component-wise clamping of values, similar to [`u32::clamp`]. + + /// + + ///Each element in `min` must be less-or-equal to the corresponding element in `max`. + + /// + + ///# Panics + + /// + + ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn clamp ( + + + self, + + + + + #[proxy] + + min : Self, + + + + + + #[proxy] + + max : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the horizontal minimum of `self`. + + /// + + ///In other words this computes `min(x, y, ..)`. + + #[lua( + + + + )] + fn min_element ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Returns the horizontal maximum of `self`. + + /// + + ///In other words this computes `max(x, y, ..)`. + + #[lua( + + + + )] + fn max_element ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `==` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpeq ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `!=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpne ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpge ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpgt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmple ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmplt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec3 + + ; +"#, + r#" + + ///Computes the squared length of `self`. + + #[lua( + + + + )] + fn length_squared ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Casts all elements of `self` to `f32`. + + #[lua( + + + + output(proxy), + + )] + fn as_vec3 ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Casts all elements of `self` to `f32`. + + #[lua( + + + + output(proxy), + + )] + fn as_vec3a ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + ///Casts all elements of `self` to `f64`. + + #[lua( + + + + output(proxy), + + )] + fn as_dvec3 ( + + + &self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + ///Casts all elements of `self` to `i32`. + + #[lua( + + + + output(proxy), + + )] + fn as_ivec3 ( + + + &self, + + + ) + + + -> bevy::math::i32::IVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xxzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xyzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn xzzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yxzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yyzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn yzzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zxzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zyzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::Vec3Swizzles", + + + output(proxy), + + )] + fn zzzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + ] +)] +pub struct UVec3; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::u32::UVec4", + functions[r#" + + ///Creates a new vector. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn new ( + + + + x : u32, + + + + + + y : u32, + + + + + + z : u32, + + + + + + w : u32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector with all elements set to `v`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn splat ( + + + + v : u32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a vector from the elements in `if_true` and `if_false`, selecting which to use + + ///for each element of `self`. + + /// + + ///A true element in the mask uses the corresponding element from `if_true`, and false + + ///uses the element from `if_false`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn select ( + + + + #[proxy] + + mask : bevy::math::bool::BVec4, + + + + + + #[proxy] + + if_true : Self, + + + + + + #[proxy] + + if_false : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 2D vector from the `x`, `y` and `z` elements of `self`, discarding `w`. + + /// + + ///Truncation to [`UVec3`] may also be performed by using [`self.xyz()`][crate::swizzles::Vec4Swizzles::xyz()]. + + #[lua( + + + + output(proxy), + + )] + fn truncate ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + ///Computes the dot product of `self` and `rhs`. + + #[lua( + + + + )] + fn dot ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Returns a vector where every component is the dot product of `self` and `rhs`. + + #[lua( + + + + output(proxy), + + )] + fn dot_into_vec ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the minimum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.min(rhs.x), self.y.min(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn min ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns a vector containing the maximum values for each element of `self` and `rhs`. + + /// + + ///In other words this computes `[self.x.max(rhs.x), self.y.max(rhs.y), ..]`. + + #[lua( + + + + output(proxy), + + )] + fn max ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Component-wise clamping of values, similar to [`u32::clamp`]. + + /// + + ///Each element in `min` must be less-or-equal to the corresponding element in `max`. + + /// + + ///# Panics + + /// + + ///Will panic if `min` is greater than `max` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn clamp ( + + + self, + + + + + #[proxy] + + min : Self, + + + + + + #[proxy] + + max : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the horizontal minimum of `self`. + + /// + + ///In other words this computes `min(x, y, ..)`. + + #[lua( + + + + )] + fn min_element ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Returns the horizontal maximum of `self`. + + /// + + ///In other words this computes `max(x, y, ..)`. + + #[lua( + + + + )] + fn max_element ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `==` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words, this computes `[self.x == rhs.x, self.y == rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpeq ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec4 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `!=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x != rhs.x, self.y != rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpne ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec4 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x >= rhs.x, self.y >= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpge ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec4 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `>` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x > rhs.x, self.y > rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmpgt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec4 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<=` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x <= rhs.x, self.y <= rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmple ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec4 + + ; +"#, + r#" + + ///Returns a vector mask containing the result of a `<` comparison for each element of + + ///`self` and `rhs`. + + /// + + ///In other words this computes `[self.x < rhs.x, self.y < rhs.y, ..]` for all + + ///elements. + + #[lua( + + + + output(proxy), + + )] + fn cmplt ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> bevy::math::bool::BVec4 + + ; +"#, + r#" + + ///Computes the squared length of `self`. + + #[lua( + + + + )] + fn length_squared ( + + + self, + + + ) + + + -> u32 + + ; +"#, + r#" + + ///Casts all elements of `self` to `f32`. + + #[lua( + + + + output(proxy), + + )] + fn as_vec4 ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + ///Casts all elements of `self` to `f64`. + + #[lua( + + + + output(proxy), + + )] + fn as_dvec4 ( + + + &self, + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + ///Casts all elements of `self` to `i32`. + + #[lua( + + + + output(proxy), + + )] + fn as_ivec4 ( + + + &self, + + + ) + + + -> bevy::math::i32::IVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ww ( + + + self, + + + ) + + + -> bevy::math::u32::UVec2 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xww ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yww ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zww ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn www ( + + + self, + + + ) + + + -> bevy::math::u32::UVec3 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxxw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxyw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxzw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxwx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxwy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxwz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xxww ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyxw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyyw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyzw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xywx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xywy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xywz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xyww ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzxw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzyw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzzw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzwx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzwy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzwz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xzww ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwxw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwyw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwzw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwwx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwwy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwwz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn xwww ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxxw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxyw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxzw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxwx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxwy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxwz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yxww ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyxw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyyw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyzw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yywx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yywy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yywz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yyww ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzxw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzyw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzzw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzwx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzwy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzwz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn yzww ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywxw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywyw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywzw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywwx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywwy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywwz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn ywww ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxxw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxyw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxzw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxwx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxwy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxwz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zxww ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyxw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyyw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyzw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zywx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zywy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zywz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zyww ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzxw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzyw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzzw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzwx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzwy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzwz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zzww ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwxw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwyw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwzw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwwx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwwy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwwz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn zwww ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxxw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxyw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxzw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxwx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxwy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxwz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wxww ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyxw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyyw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyzw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wywx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wywy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wywz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wyww ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzxw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzyw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzzw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzwx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzwy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzwz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wzww ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwxx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwxy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwxz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwxw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwyx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwyy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwyz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwyw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwzx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwzy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwzz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwzw ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwwx ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwwy ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwwz ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + r#" + + #[lua( + + + as_trait="bevy::math::swizzles::Vec4Swizzles", + + + output(proxy), + + )] + fn wwww ( + + + self, + + + ) + + + -> bevy::math::u32::UVec4 + + ; +"#, + ] +)] +pub struct UVec4; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::f32::Mat3", + functions[r#" + + ///Creates a 3x3 matrix from three column vectors. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_cols ( + + + + #[proxy] + + x_axis : bevy::math::f32::Vec3, + + + + + + #[proxy] + + y_axis : bevy::math::f32::Vec3, + + + + + + #[proxy] + + z_axis : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3x3 matrix with its diagonal set to `diagonal` and all other entries set to 0. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_diagonal ( + + + + #[proxy] + + diagonal : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3x3 matrix from a 4x4 matrix, discarding the 4th row and column. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat4 ( + + + + #[proxy] + + m : bevy::math::f32::Mat4, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3D rotation matrix from the given quaternion. + + /// + + ///# Panics + + /// + + ///Will panic if `rotation` is not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_quat ( + + + + #[proxy] + + rotation : bevy::math::f32::Quat, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3D rotation matrix from a normalized rotation `axis` and `angle` (in + + ///radians). + + /// + + ///# Panics + + /// + + ///Will panic if `axis` is not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_axis_angle ( + + + + #[proxy] + + axis : bevy::math::f32::Vec3, + + + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3D rotation matrix from the given euler rotation sequence and the angles (in + + ///radians). + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_euler ( + + + + #[proxy] + + order : bevy::math::EulerRot, + + + + + + a : f32, + + + + + + b : f32, + + + + + + c : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3D rotation matrix from `angle` (in radians) around the x axis. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_x ( + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3D rotation matrix from `angle` (in radians) around the y axis. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_y ( + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3D rotation matrix from `angle` (in radians) around the z axis. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_z ( + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given 2D `translation`. + + /// + + ///The resulting matrix can be used to transform 2D points and vectors. See + + ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_translation ( + + + + #[proxy] + + translation : bevy::math::f32::Vec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given 2D rotation `angle` (in + + ///radians). + + /// + + ///The resulting matrix can be used to transform 2D points and vectors. See + + ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_angle ( + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given 2D `scale`, rotation `angle` (in + + ///radians) and `translation`. + + /// + + ///The resulting matrix can be used to transform 2D points and vectors. See + + ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_scale_angle_translation ( + + + + #[proxy] + + scale : bevy::math::f32::Vec2, + + + + + + angle : f32, + + + + + + #[proxy] + + translation : bevy::math::f32::Vec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given non-uniform 2D `scale`. + + /// + + ///The resulting matrix can be used to transform 2D points and vectors. See + + ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + /// + + ///# Panics + + /// + + ///Will panic if all elements of `scale` are zero when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_scale ( + + + + #[proxy] + + scale : bevy::math::f32::Vec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given 2x2 matrix. + + /// + + ///The resulting matrix can be used to transform 2D points and vectors. See + + ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat2 ( + + + + #[proxy] + + m : bevy::math::f32::Mat2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the matrix column for the given `index`. + + /// + + ///# Panics + + /// + + ///Panics if `index` is greater than 2. + + #[lua( + + + + output(proxy), + + )] + fn col ( + + + &self, + + + + + index : usize, + + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Returns the matrix row for the given `index`. + + /// + + ///# Panics + + /// + + ///Panics if `index` is greater than 2. + + #[lua( + + + + output(proxy), + + )] + fn row ( + + + &self, + + + + + index : usize, + + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Returns `true` if, and only if, all elements are finite. + + ///If any element is either `NaN`, positive or negative infinity, this will return `false`. + + #[lua( + + + + )] + fn is_finite ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns `true` if any elements are `NaN`. + + #[lua( + + + + )] + fn is_nan ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns the transpose of `self`. + + #[lua( + + + + output(proxy), + + )] + fn transpose ( + + + &self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the determinant of `self`. + + #[lua( + + + + )] + fn determinant ( + + + &self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns the inverse of `self`. + + /// + + ///If the matrix is not invertible the returned matrix will be invalid. + + /// + + ///# Panics + + /// + + ///Will panic if the determinant of `self` is zero when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn inverse ( + + + &self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Transforms the given 2D vector as a point. + + /// + + ///This is the equivalent of multiplying `rhs` as a 3D vector where `z` is `1`. + + /// + + ///This method assumes that `self` contains a valid affine transform. + + /// + + ///# Panics + + /// + + ///Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn transform_point2 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f32::Vec2, + + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + ///Rotates the given 2D vector. + + /// + + ///This is the equivalent of multiplying `rhs` as a 3D vector where `z` is `0`. + + /// + + ///This method assumes that `self` contains a valid affine transform. + + /// + + ///# Panics + + /// + + ///Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn transform_vector2 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f32::Vec2, + + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + ///Transforms a 3D vector. + + #[lua( + + + + output(proxy), + + )] + fn mul_vec3 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f32::Vec3, + + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Transforms a [`Vec3A`]. + + #[lua( + + + + output(proxy), + + )] + fn mul_vec3a ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f32::Vec3A, + + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + ///Multiplies a 3x3 matrix by a scalar. + + #[lua( + + + + output(proxy), + + )] + fn mul_scalar ( + + + &self, + + + + + rhs : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns true if the absolute difference of all elements between `self` and `rhs` + + ///is less than or equal to `max_abs_diff`. + + /// + + ///This can be used to compare if two matrices contain similar elements. It works best + + ///when comparing with a known value. The `max_abs_diff` that should be used used + + ///depends on the values being compared against. + + /// + + ///For more see + + ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua( + + + + )] + fn abs_diff_eq ( + + + &self, + + + + + #[proxy] + + rhs : Self, + + + + + + max_abs_diff : f32, + + + + ) + + + -> bool + + ; +"#, + r#" + + #[lua( + + + + output(proxy), + + )] + fn as_dmat3 ( + + + &self, + + + ) + + + -> bevy::math::f64::DMat3 + + ; +"#, + ] +)] +pub struct Mat3; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::f32::Mat2", + functions[r#" + + ///Creates a 2x2 matrix from two column vectors. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_cols ( + + + + #[proxy] + + x_axis : bevy::math::f32::Vec2, + + + + + + #[proxy] + + y_axis : bevy::math::f32::Vec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 2x2 matrix with its diagonal set to `diagonal` and all other entries set to 0. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_diagonal ( + + + + #[proxy] + + diagonal : bevy::math::f32::Vec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 2x2 matrix containing the combining non-uniform `scale` and rotation of + + ///`angle` (in radians). + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_scale_angle ( + + + + #[proxy] + + scale : bevy::math::f32::Vec2, + + + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 2x2 matrix containing a rotation of `angle` (in radians). + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_angle ( + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat3 ( + + + + #[proxy] + + m : bevy::math::f32::Mat3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat3a ( + + + + #[proxy] + + m : bevy::math::f32::Mat3A, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the matrix column for the given `index`. + + /// + + ///# Panics + + /// + + ///Panics if `index` is greater than 1. + + #[lua( + + + + output(proxy), + + )] + fn col ( + + + &self, + + + + + index : usize, + + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + ///Returns the matrix row for the given `index`. + + /// + + ///# Panics + + /// + + ///Panics if `index` is greater than 1. + + #[lua( + + + + output(proxy), + + )] + fn row ( + + + &self, + + + + + index : usize, + + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + ///Returns `true` if, and only if, all elements are finite. + + ///If any element is either `NaN`, positive or negative infinity, this will return `false`. + + #[lua( + + + + )] + fn is_finite ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns `true` if any elements are `NaN`. + + #[lua( + + + + )] + fn is_nan ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns the transpose of `self`. + + #[lua( + + + + output(proxy), + + )] + fn transpose ( + + + &self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the determinant of `self`. + + #[lua( + + + + )] + fn determinant ( + + + &self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns the inverse of `self`. + + /// + + ///If the matrix is not invertible the returned matrix will be invalid. + + /// + + ///# Panics + + /// + + ///Will panic if the determinant of `self` is zero when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn inverse ( + + + &self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Transforms a 2D vector. + + #[lua( + + + + output(proxy), + + )] + fn mul_vec2 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f32::Vec2, + + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + ///Multiplies a 2x2 matrix by a scalar. + + #[lua( + + + + output(proxy), + + )] + fn mul_scalar ( + + + &self, + + + + + rhs : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns true if the absolute difference of all elements between `self` and `rhs` + + ///is less than or equal to `max_abs_diff`. + + /// + + ///This can be used to compare if two matrices contain similar elements. It works best + + ///when comparing with a known value. The `max_abs_diff` that should be used used + + ///depends on the values being compared against. + + /// + + ///For more see + + ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua( + + + + )] + fn abs_diff_eq ( + + + &self, + + + + + #[proxy] + + rhs : Self, + + + + + + max_abs_diff : f32, + + + + ) + + + -> bool + + ; +"#, + r#" + + #[lua( + + + + output(proxy), + + )] + fn as_dmat2 ( + + + &self, + + + ) + + + -> bevy::math::f64::DMat2 + + ; +"#, + ] +)] +pub struct Mat2; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::f32::Mat3A", + functions[r#" + + ///Creates a 3x3 matrix from three column vectors. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_cols ( + + + + #[proxy] + + x_axis : bevy::math::f32::Vec3A, + + + + + + #[proxy] + + y_axis : bevy::math::f32::Vec3A, + + + + + + #[proxy] + + z_axis : bevy::math::f32::Vec3A, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3x3 matrix with its diagonal set to `diagonal` and all other entries set to 0. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_diagonal ( + + + + #[proxy] + + diagonal : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3x3 matrix from a 4x4 matrix, discarding the 4th row and column. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat4 ( + + + + #[proxy] + + m : bevy::math::f32::Mat4, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3D rotation matrix from the given quaternion. + + /// + + ///# Panics + + /// + + ///Will panic if `rotation` is not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_quat ( + + + + #[proxy] + + rotation : bevy::math::f32::Quat, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3D rotation matrix from a normalized rotation `axis` and `angle` (in + + ///radians). + + /// + + ///# Panics + + /// + + ///Will panic if `axis` is not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_axis_angle ( + + + + #[proxy] + + axis : bevy::math::f32::Vec3, + + + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3D rotation matrix from the given euler rotation sequence and the angles (in + + ///radians). + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_euler ( + + + + #[proxy] + + order : bevy::math::EulerRot, + + + + + + a : f32, + + + + + + b : f32, + + + + + + c : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3D rotation matrix from `angle` (in radians) around the x axis. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_x ( + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3D rotation matrix from `angle` (in radians) around the y axis. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_y ( + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3D rotation matrix from `angle` (in radians) around the z axis. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_z ( + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given 2D `translation`. + + /// + + ///The resulting matrix can be used to transform 2D points and vectors. See + + ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_translation ( + + + + #[proxy] + + translation : bevy::math::f32::Vec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given 2D rotation `angle` (in + + ///radians). + + /// + + ///The resulting matrix can be used to transform 2D points and vectors. See + + ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_angle ( + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given 2D `scale`, rotation `angle` (in + + ///radians) and `translation`. + + /// + + ///The resulting matrix can be used to transform 2D points and vectors. See + + ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_scale_angle_translation ( + + + + #[proxy] + + scale : bevy::math::f32::Vec2, + + + + + + angle : f32, + + + + + + #[proxy] + + translation : bevy::math::f32::Vec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given non-uniform 2D `scale`. + + /// + + ///The resulting matrix can be used to transform 2D points and vectors. See + + ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + /// + + ///# Panics + + /// + + ///Will panic if all elements of `scale` are zero when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_scale ( + + + + #[proxy] + + scale : bevy::math::f32::Vec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given 2x2 matrix. + + /// + + ///The resulting matrix can be used to transform 2D points and vectors. See + + ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat2 ( + + + + #[proxy] + + m : bevy::math::f32::Mat2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the matrix column for the given `index`. + + /// + + ///# Panics + + /// + + ///Panics if `index` is greater than 2. + + #[lua( + + + + output(proxy), + + )] + fn col ( + + + &self, + + + + + index : usize, + + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + ///Returns the matrix row for the given `index`. + + /// + + ///# Panics + + /// + + ///Panics if `index` is greater than 2. + + #[lua( + + + + output(proxy), + + )] + fn row ( + + + &self, + + + + + index : usize, + + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + ///Returns `true` if, and only if, all elements are finite. + + ///If any element is either `NaN`, positive or negative infinity, this will return `false`. + + #[lua( + + + + )] + fn is_finite ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns `true` if any elements are `NaN`. + + #[lua( + + + + )] + fn is_nan ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns the transpose of `self`. + + #[lua( + + + + output(proxy), + + )] + fn transpose ( + + + &self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the determinant of `self`. + + #[lua( + + + + )] + fn determinant ( + + + &self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns the inverse of `self`. + + /// + + ///If the matrix is not invertible the returned matrix will be invalid. + + /// + + ///# Panics + + /// + + ///Will panic if the determinant of `self` is zero when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn inverse ( + + + &self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Transforms the given 2D vector as a point. + + /// + + ///This is the equivalent of multiplying `rhs` as a 3D vector where `z` is `1`. + + /// + + ///This method assumes that `self` contains a valid affine transform. + + /// + + ///# Panics + + /// + + ///Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn transform_point2 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f32::Vec2, + + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + ///Rotates the given 2D vector. + + /// + + ///This is the equivalent of multiplying `rhs` as a 3D vector where `z` is `0`. + + /// + + ///This method assumes that `self` contains a valid affine transform. + + /// + + ///# Panics + + /// + + ///Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn transform_vector2 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f32::Vec2, + + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + ///Transforms a 3D vector. + + #[lua( + + + + output(proxy), + + )] + fn mul_vec3 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f32::Vec3, + + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Transforms a [`Vec3A`]. + + #[lua( + + + + output(proxy), + + )] + fn mul_vec3a ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f32::Vec3A, + + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + ///Multiplies a 3x3 matrix by a scalar. + + #[lua( + + + + output(proxy), + + )] + fn mul_scalar ( + + + &self, + + + + + rhs : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns true if the absolute difference of all elements between `self` and `rhs` + + ///is less than or equal to `max_abs_diff`. + + /// + + ///This can be used to compare if two matrices contain similar elements. It works best + + ///when comparing with a known value. The `max_abs_diff` that should be used used + + ///depends on the values being compared against. + + /// + + ///For more see + + ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua( + + + + )] + fn abs_diff_eq ( + + + &self, + + + + + #[proxy] + + rhs : Self, + + + + + + max_abs_diff : f32, + + + + ) + + + -> bool + + ; +"#, + r#" + + #[lua( + + + + output(proxy), + + )] + fn as_dmat3 ( + + + &self, + + + ) + + + -> bevy::math::f64::DMat3 + + ; +"#, + ] +)] +pub struct Mat3A; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::f32::Mat4", + functions[r#" + + ///Creates a 4x4 matrix from four column vectors. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_cols ( + + + + #[proxy] + + x_axis : bevy::math::f32::Vec4, + + + + + + #[proxy] + + y_axis : bevy::math::f32::Vec4, + + + + + + #[proxy] + + z_axis : bevy::math::f32::Vec4, + + + + + + #[proxy] + + w_axis : bevy::math::f32::Vec4, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 4x4 matrix with its diagonal set to `diagonal` and all other entries set to 0. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_diagonal ( + + + + #[proxy] + + diagonal : bevy::math::f32::Vec4, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given 3D `scale`, `rotation` and + + ///`translation`. + + /// + + ///The resulting matrix can be used to transform 3D points and vectors. See + + ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + /// + + ///# Panics + + /// + + ///Will panic if `rotation` is not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_scale_rotation_translation ( + + + + #[proxy] + + scale : bevy::math::f32::Vec3, + + + + + + #[proxy] + + rotation : bevy::math::f32::Quat, + + + + + + #[proxy] + + translation : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given 3D `translation`. + + /// + + ///The resulting matrix can be used to transform 3D points and vectors. See + + ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + /// + + ///# Panics + + /// + + ///Will panic if `rotation` is not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_translation ( + + + + #[proxy] + + rotation : bevy::math::f32::Quat, + + + + + + #[proxy] + + translation : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given `rotation` quaternion. + + /// + + ///The resulting matrix can be used to transform 3D points and vectors. See + + ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + /// + + ///# Panics + + /// + + ///Will panic if `rotation` is not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_quat ( + + + + #[proxy] + + rotation : bevy::math::f32::Quat, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given 3x3 linear transformation + + ///matrix. + + /// + + ///The resulting matrix can be used to transform 3D points and vectors. See + + ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat3 ( + + + + #[proxy] + + m : bevy::math::f32::Mat3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given 3x3 linear transformation + + ///matrix. + + /// + + ///The resulting matrix can be used to transform 3D points and vectors. See + + ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat3a ( + + + + #[proxy] + + m : bevy::math::f32::Mat3A, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given 3D `translation`. + + /// + + ///The resulting matrix can be used to transform 3D points and vectors. See + + ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_translation ( + + + + #[proxy] + + translation : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix containing a 3D rotation around a normalized + + ///rotation `axis` of `angle` (in radians). + + /// + + ///The resulting matrix can be used to transform 3D points and vectors. See + + ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + /// + + ///# Panics + + /// + + ///Will panic if `axis` is not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_axis_angle ( + + + + #[proxy] + + axis : bevy::math::f32::Vec3, + + + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a affine transformation matrix containing a rotation from the given euler + + ///rotation sequence and angles (in radians). + + /// + + ///The resulting matrix can be used to transform 3D points and vectors. See + + ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_euler ( + + + + #[proxy] + + order : bevy::math::EulerRot, + + + + + + a : f32, + + + + + + b : f32, + + + + + + c : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix containing a 3D rotation around the x axis of + + ///`angle` (in radians). + + /// + + ///The resulting matrix can be used to transform 3D points and vectors. See + + ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_x ( + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix containing a 3D rotation around the y axis of + + ///`angle` (in radians). + + /// + + ///The resulting matrix can be used to transform 3D points and vectors. See + + ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_y ( + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix containing a 3D rotation around the z axis of + + ///`angle` (in radians). + + /// + + ///The resulting matrix can be used to transform 3D points and vectors. See + + ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_z ( + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix containing the given 3D non-uniform `scale`. + + /// + + ///The resulting matrix can be used to transform 3D points and vectors. See + + ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + /// + + ///# Panics + + /// + + ///Will panic if all elements of `scale` are zero when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_scale ( + + + + #[proxy] + + scale : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the matrix column for the given `index`. + + /// + + ///# Panics + + /// + + ///Panics if `index` is greater than 3. + + #[lua( + + + + output(proxy), + + )] + fn col ( + + + &self, + + + + + index : usize, + + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + ///Returns the matrix row for the given `index`. + + /// + + ///# Panics + + /// + + ///Panics if `index` is greater than 3. + + #[lua( + + + + output(proxy), + + )] + fn row ( + + + &self, + + + + + index : usize, + + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + ///Returns `true` if, and only if, all elements are finite. + + ///If any element is either `NaN`, positive or negative infinity, this will return `false`. + + #[lua( + + + + )] + fn is_finite ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns `true` if any elements are `NaN`. + + #[lua( + + + + )] + fn is_nan ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns the transpose of `self`. + + #[lua( + + + + output(proxy), + + )] + fn transpose ( + + + &self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the determinant of `self`. + + #[lua( + + + + )] + fn determinant ( + + + &self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns the inverse of `self`. + + /// + + ///If the matrix is not invertible the returned matrix will be invalid. + + /// + + ///# Panics + + /// + + ///Will panic if the determinant of `self` is zero when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn inverse ( + + + &self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a left-handed view matrix using a camera position, an up direction, and a facing + + ///direction. + + /// + + ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn look_to_lh ( + + + + #[proxy] + + eye : bevy::math::f32::Vec3, + + + + + + #[proxy] + + dir : bevy::math::f32::Vec3, + + + + + + #[proxy] + + up : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a right-handed view matrix using a camera position, an up direction, and a facing + + ///direction. + + /// + + ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn look_to_rh ( + + + + #[proxy] + + eye : bevy::math::f32::Vec3, + + + + + + #[proxy] + + dir : bevy::math::f32::Vec3, + + + + + + #[proxy] + + up : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a left-handed view matrix using a camera position, an up direction, and a focal + + ///point. + + ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. + + /// + + ///# Panics + + /// + + ///Will panic if `up` is not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn look_at_lh ( + + + + #[proxy] + + eye : bevy::math::f32::Vec3, + + + + + + #[proxy] + + center : bevy::math::f32::Vec3, + + + + + + #[proxy] + + up : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a right-handed view matrix using a camera position, an up direction, and a focal + + ///point. + + ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. + + /// + + ///# Panics + + /// + + ///Will panic if `up` is not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn look_at_rh ( + + + + #[proxy] + + eye : bevy::math::f32::Vec3, + + + + + + #[proxy] + + center : bevy::math::f32::Vec3, + + + + + + #[proxy] + + up : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a right-handed perspective projection matrix with [-1,1] depth range. + + ///This is the same as the OpenGL `gluPerspective` function. + + ///See + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn perspective_rh_gl ( + + + + fov_y_radians : f32, + + + + + + aspect_ratio : f32, + + + + + + z_near : f32, + + + + + + z_far : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a left-handed perspective projection matrix with `[0,1]` depth range. + + /// + + ///# Panics + + /// + + ///Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is + + ///enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn perspective_lh ( + + + + fov_y_radians : f32, + + + + + + aspect_ratio : f32, + + + + + + z_near : f32, + + + + + + z_far : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a right-handed perspective projection matrix with `[0,1]` depth range. + + /// + + ///# Panics + + /// + + ///Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is + + ///enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn perspective_rh ( + + + + fov_y_radians : f32, + + + + + + aspect_ratio : f32, + + + + + + z_near : f32, + + + + + + z_far : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an infinite left-handed perspective projection matrix with `[0,1]` depth range. + + /// + + ///# Panics + + /// + + ///Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn perspective_infinite_lh ( + + + + fov_y_radians : f32, + + + + + + aspect_ratio : f32, + + + + + + z_near : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an infinite left-handed perspective projection matrix with `[0,1]` depth range. + + /// + + ///# Panics + + /// + + ///Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn perspective_infinite_reverse_lh ( + + + + fov_y_radians : f32, + + + + + + aspect_ratio : f32, + + + + + + z_near : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an infinite right-handed perspective projection matrix with + + ///`[0,1]` depth range. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn perspective_infinite_rh ( + + + + fov_y_radians : f32, + + + + + + aspect_ratio : f32, + + + + + + z_near : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an infinite reverse right-handed perspective projection matrix + + ///with `[0,1]` depth range. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn perspective_infinite_reverse_rh ( + + + + fov_y_radians : f32, + + + + + + aspect_ratio : f32, + + + + + + z_near : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a right-handed orthographic projection matrix with `[-1,1]` depth + + ///range. This is the same as the OpenGL `glOrtho` function in OpenGL. + + ///See + + /// + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn orthographic_rh_gl ( + + + + left : f32, + + + + + + right : f32, + + + + + + bottom : f32, + + + + + + top : f32, + + + + + + near : f32, + + + + + + far : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a left-handed orthographic projection matrix with `[0,1]` depth range. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn orthographic_lh ( + + + + left : f32, + + + + + + right : f32, + + + + + + bottom : f32, + + + + + + top : f32, + + + + + + near : f32, + + + + + + far : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a right-handed orthographic projection matrix with `[0,1]` depth range. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn orthographic_rh ( + + + + left : f32, + + + + + + right : f32, + + + + + + bottom : f32, + + + + + + top : f32, + + + + + + near : f32, + + + + + + far : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Transforms the given 3D vector as a point, applying perspective correction. + + /// + + ///This is the equivalent of multiplying the 3D vector as a 4D vector where `w` is `1.0`. + + ///The perspective divide is performed meaning the resulting 3D vector is divided by `w`. + + /// + + ///This method assumes that `self` contains a projective transform. + + #[lua( + + + + output(proxy), + + )] + fn project_point3 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f32::Vec3, + + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Transforms the given 3D vector as a point. + + /// + + ///This is the equivalent of multiplying the 3D vector as a 4D vector where `w` is + + ///`1.0`. + + /// + + ///This method assumes that `self` contains a valid affine transform. It does not perform + + ///a persective divide, if `self` contains a perspective transform, or if you are unsure, + + ///the [`Self::project_point3()`] method should be used instead. + + /// + + ///# Panics + + /// + + ///Will panic if the 3rd row of `self` is not `(0, 0, 0, 1)` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn transform_point3 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f32::Vec3, + + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Transforms the give 3D vector as a direction. + + /// + + ///This is the equivalent of multiplying the 3D vector as a 4D vector where `w` is + + ///`0.0`. + + /// + + ///This method assumes that `self` contains a valid affine transform. + + /// + + ///# Panics + + /// + + ///Will panic if the 3rd row of `self` is not `(0, 0, 0, 1)` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn transform_vector3 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f32::Vec3, + + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Transforms the given [`Vec3A`] as 3D point. + + /// + + ///This is the equivalent of multiplying the [`Vec3A`] as a 4D vector where `w` is `1.0`. + + #[lua( + + + + output(proxy), + + )] + fn transform_point3a ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f32::Vec3A, + + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + ///Transforms the give [`Vec3A`] as 3D vector. + + /// + + ///This is the equivalent of multiplying the [`Vec3A`] as a 4D vector where `w` is `0.0`. + + #[lua( + + + + output(proxy), + + )] + fn transform_vector3a ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f32::Vec3A, + + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + ///Transforms a 4D vector. + + #[lua( + + + + output(proxy), + + )] + fn mul_vec4 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f32::Vec4, + + + + ) + + + -> bevy::math::f32::Vec4 + + ; +"#, + r#" + + ///Multiplies a 4x4 matrix by a scalar. + + #[lua( + + + + output(proxy), + + )] + fn mul_scalar ( + + + &self, + + + + + rhs : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns true if the absolute difference of all elements between `self` and `rhs` + + ///is less than or equal to `max_abs_diff`. + + /// + + ///This can be used to compare if two matrices contain similar elements. It works best + + ///when comparing with a known value. The `max_abs_diff` that should be used used + + ///depends on the values being compared against. + + /// + + ///For more see + + ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua( + + + + )] + fn abs_diff_eq ( + + + &self, + + + + + #[proxy] + + rhs : Self, + + + + + + max_abs_diff : f32, + + + + ) + + + -> bool + + ; +"#, + r#" + + #[lua( + + + + output(proxy), + + )] + fn as_dmat4 ( + + + &self, + + + ) + + + -> bevy::math::f64::DMat4 + + ; +"#, + ] +)] +pub struct Mat4; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::f64::DMat2", + functions[r#" + + ///Creates a 2x2 matrix from two column vectors. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_cols ( + + + + #[proxy] + + x_axis : bevy::math::f64::DVec2, + + + + + + #[proxy] + + y_axis : bevy::math::f64::DVec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 2x2 matrix with its diagonal set to `diagonal` and all other entries set to 0. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_diagonal ( + + + + #[proxy] + + diagonal : bevy::math::f64::DVec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 2x2 matrix containing the combining non-uniform `scale` and rotation of + + ///`angle` (in radians). + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_scale_angle ( + + + + #[proxy] + + scale : bevy::math::f64::DVec2, + + + + + + angle : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 2x2 matrix containing a rotation of `angle` (in radians). + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_angle ( + + + + angle : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat3 ( + + + + #[proxy] + + m : bevy::math::f64::DMat3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the matrix column for the given `index`. + + /// + + ///# Panics + + /// + + ///Panics if `index` is greater than 1. + + #[lua( + + + + output(proxy), + + )] + fn col ( + + + &self, + + + + + index : usize, + + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + ///Returns the matrix row for the given `index`. + + /// + + ///# Panics + + /// + + ///Panics if `index` is greater than 1. + + #[lua( + + + + output(proxy), + + )] + fn row ( + + + &self, + + + + + index : usize, + + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + ///Returns `true` if, and only if, all elements are finite. + + ///If any element is either `NaN`, positive or negative infinity, this will return `false`. + + #[lua( + + + + )] + fn is_finite ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns `true` if any elements are `NaN`. + + #[lua( + + + + )] + fn is_nan ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns the transpose of `self`. + + #[lua( + + + + output(proxy), + + )] + fn transpose ( + + + &self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the determinant of `self`. + + #[lua( + + + + )] + fn determinant ( + + + &self, + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Returns the inverse of `self`. + + /// + + ///If the matrix is not invertible the returned matrix will be invalid. + + /// + + ///# Panics + + /// + + ///Will panic if the determinant of `self` is zero when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn inverse ( + + + &self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Transforms a 2D vector. + + #[lua( + + + + output(proxy), + + )] + fn mul_vec2 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f64::DVec2, + + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + ///Multiplies a 2x2 matrix by a scalar. + + #[lua( + + + + output(proxy), + + )] + fn mul_scalar ( + + + &self, + + + + + rhs : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns true if the absolute difference of all elements between `self` and `rhs` + + ///is less than or equal to `max_abs_diff`. + + /// + + ///This can be used to compare if two matrices contain similar elements. It works best + + ///when comparing with a known value. The `max_abs_diff` that should be used used + + ///depends on the values being compared against. + + /// + + ///For more see + + ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua( + + + + )] + fn abs_diff_eq ( + + + &self, + + + + + #[proxy] + + rhs : Self, + + + + + + max_abs_diff : f64, + + + + ) + + + -> bool + + ; +"#, + r#" + + #[lua( + + + + output(proxy), + + )] + fn as_mat2 ( + + + &self, + + + ) + + + -> bevy::math::f32::Mat2 + + ; +"#, + ] +)] +pub struct DMat2; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::f64::DMat3", + functions[r#" + + ///Creates a 3x3 matrix from three column vectors. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_cols ( + + + + #[proxy] + + x_axis : bevy::math::f64::DVec3, + + + + + + #[proxy] + + y_axis : bevy::math::f64::DVec3, + + + + + + #[proxy] + + z_axis : bevy::math::f64::DVec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3x3 matrix with its diagonal set to `diagonal` and all other entries set to 0. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_diagonal ( + + + + #[proxy] + + diagonal : bevy::math::f64::DVec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3x3 matrix from a 4x4 matrix, discarding the 4th row and column. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat4 ( + + + + #[proxy] + + m : bevy::math::f64::DMat4, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3D rotation matrix from the given quaternion. + + /// + + ///# Panics + + /// + + ///Will panic if `rotation` is not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_quat ( + + + + #[proxy] + + rotation : bevy::math::f64::DQuat, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3D rotation matrix from a normalized rotation `axis` and `angle` (in + + ///radians). + + /// + + ///# Panics + + /// + + ///Will panic if `axis` is not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_axis_angle ( + + + + #[proxy] + + axis : bevy::math::f64::DVec3, + + + + + + angle : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3D rotation matrix from the given euler rotation sequence and the angles (in + + ///radians). + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_euler ( + + + + #[proxy] + + order : bevy::math::EulerRot, + + + + + + a : f64, + + + + + + b : f64, + + + + + + c : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3D rotation matrix from `angle` (in radians) around the x axis. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_x ( + + + + angle : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3D rotation matrix from `angle` (in radians) around the y axis. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_y ( + + + + angle : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 3D rotation matrix from `angle` (in radians) around the z axis. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_z ( + + + + angle : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given 2D `translation`. + + /// + + ///The resulting matrix can be used to transform 2D points and vectors. See + + ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_translation ( + + + + #[proxy] + + translation : bevy::math::f64::DVec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given 2D rotation `angle` (in + + ///radians). + + /// + + ///The resulting matrix can be used to transform 2D points and vectors. See + + ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_angle ( + + + + angle : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given 2D `scale`, rotation `angle` (in + + ///radians) and `translation`. + + /// + + ///The resulting matrix can be used to transform 2D points and vectors. See + + ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_scale_angle_translation ( + + + + #[proxy] + + scale : bevy::math::f64::DVec2, + + + + + + angle : f64, + + + + + + #[proxy] + + translation : bevy::math::f64::DVec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given non-uniform 2D `scale`. + + /// + + ///The resulting matrix can be used to transform 2D points and vectors. See + + ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + /// + + ///# Panics + + /// + + ///Will panic if all elements of `scale` are zero when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_scale ( + + + + #[proxy] + + scale : bevy::math::f64::DVec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given 2x2 matrix. + + /// + + ///The resulting matrix can be used to transform 2D points and vectors. See + + ///[`Self::transform_point2()`] and [`Self::transform_vector2()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat2 ( + + + + #[proxy] + + m : bevy::math::f64::DMat2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the matrix column for the given `index`. + + /// + + ///# Panics + + /// + + ///Panics if `index` is greater than 2. + + #[lua( + + + + output(proxy), + + )] + fn col ( + + + &self, + + + + + index : usize, + + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + ///Returns the matrix row for the given `index`. + + /// + + ///# Panics + + /// + + ///Panics if `index` is greater than 2. + + #[lua( + + + + output(proxy), + + )] + fn row ( + + + &self, + + + + + index : usize, + + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + ///Returns `true` if, and only if, all elements are finite. + + ///If any element is either `NaN`, positive or negative infinity, this will return `false`. + + #[lua( + + + + )] + fn is_finite ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns `true` if any elements are `NaN`. + + #[lua( + + + + )] + fn is_nan ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns the transpose of `self`. + + #[lua( + + + + output(proxy), + + )] + fn transpose ( + + + &self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the determinant of `self`. + + #[lua( + + + + )] + fn determinant ( + + + &self, + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Returns the inverse of `self`. + + /// + + ///If the matrix is not invertible the returned matrix will be invalid. + + /// + + ///# Panics + + /// + + ///Will panic if the determinant of `self` is zero when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn inverse ( + + + &self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Transforms the given 2D vector as a point. + + /// + + ///This is the equivalent of multiplying `rhs` as a 3D vector where `z` is `1`. + + /// + + ///This method assumes that `self` contains a valid affine transform. + + /// + + ///# Panics + + /// + + ///Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn transform_point2 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f64::DVec2, + + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + ///Rotates the given 2D vector. + + /// + + ///This is the equivalent of multiplying `rhs` as a 3D vector where `z` is `0`. + + /// + + ///This method assumes that `self` contains a valid affine transform. + + /// + + ///# Panics + + /// + + ///Will panic if the 2nd row of `self` is not `(0, 0, 1)` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn transform_vector2 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f64::DVec2, + + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + ///Transforms a 3D vector. + + #[lua( + + + + output(proxy), + + )] + fn mul_vec3 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f64::DVec3, + + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + ///Multiplies a 3x3 matrix by a scalar. + + #[lua( + + + + output(proxy), + + )] + fn mul_scalar ( + + + &self, + + + + + rhs : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns true if the absolute difference of all elements between `self` and `rhs` + + ///is less than or equal to `max_abs_diff`. + + /// + + ///This can be used to compare if two matrices contain similar elements. It works best + + ///when comparing with a known value. The `max_abs_diff` that should be used used + + ///depends on the values being compared against. + + /// + + ///For more see + + ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua( + + + + )] + fn abs_diff_eq ( + + + &self, + + + + + #[proxy] + + rhs : Self, + + + + + + max_abs_diff : f64, + + + + ) + + + -> bool + + ; +"#, + r#" + + #[lua( + + + + output(proxy), + + )] + fn as_mat3 ( + + + &self, + + + ) + + + -> bevy::math::f32::Mat3 + + ; +"#, + ] +)] +pub struct DMat3; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::f64::DMat4", + functions[r#" + + ///Creates a 4x4 matrix from four column vectors. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_cols ( + + + + #[proxy] + + x_axis : bevy::math::f64::DVec4, + + + + + + #[proxy] + + y_axis : bevy::math::f64::DVec4, + + + + + + #[proxy] + + z_axis : bevy::math::f64::DVec4, + + + + + + #[proxy] + + w_axis : bevy::math::f64::DVec4, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a 4x4 matrix with its diagonal set to `diagonal` and all other entries set to 0. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_diagonal ( + + + + #[proxy] + + diagonal : bevy::math::f64::DVec4, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given 3D `scale`, `rotation` and + + ///`translation`. + + /// + + ///The resulting matrix can be used to transform 3D points and vectors. See + + ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + /// + + ///# Panics + + /// + + ///Will panic if `rotation` is not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_scale_rotation_translation ( + + + + #[proxy] + + scale : bevy::math::f64::DVec3, + + + + + + #[proxy] + + rotation : bevy::math::f64::DQuat, + + + + + + #[proxy] + + translation : bevy::math::f64::DVec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given 3D `translation`. + + /// + + ///The resulting matrix can be used to transform 3D points and vectors. See + + ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + /// + + ///# Panics + + /// + + ///Will panic if `rotation` is not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_translation ( + + + + #[proxy] + + rotation : bevy::math::f64::DQuat, + + + + + + #[proxy] + + translation : bevy::math::f64::DVec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given `rotation` quaternion. + + /// + + ///The resulting matrix can be used to transform 3D points and vectors. See + + ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + /// + + ///# Panics + + /// + + ///Will panic if `rotation` is not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_quat ( + + + + #[proxy] + + rotation : bevy::math::f64::DQuat, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given 3x3 linear transformation + + ///matrix. + + /// + + ///The resulting matrix can be used to transform 3D points and vectors. See + + ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat3 ( + + + + #[proxy] + + m : bevy::math::f64::DMat3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix from the given 3D `translation`. + + /// + + ///The resulting matrix can be used to transform 3D points and vectors. See + + ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_translation ( + + + + #[proxy] + + translation : bevy::math::f64::DVec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix containing a 3D rotation around a normalized + + ///rotation `axis` of `angle` (in radians). + + /// + + ///The resulting matrix can be used to transform 3D points and vectors. See + + ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + /// + + ///# Panics + + /// + + ///Will panic if `axis` is not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_axis_angle ( + + + + #[proxy] + + axis : bevy::math::f64::DVec3, + + + + + + angle : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a affine transformation matrix containing a rotation from the given euler + + ///rotation sequence and angles (in radians). + + /// + + ///The resulting matrix can be used to transform 3D points and vectors. See + + ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_euler ( + + + + #[proxy] + + order : bevy::math::EulerRot, + + + + + + a : f64, + + + + + + b : f64, + + + + + + c : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix containing a 3D rotation around the x axis of + + ///`angle` (in radians). + + /// + + ///The resulting matrix can be used to transform 3D points and vectors. See + + ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_x ( + + + + angle : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix containing a 3D rotation around the y axis of + + ///`angle` (in radians). + + /// + + ///The resulting matrix can be used to transform 3D points and vectors. See + + ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_y ( + + + + angle : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix containing a 3D rotation around the z axis of + + ///`angle` (in radians). + + /// + + ///The resulting matrix can be used to transform 3D points and vectors. See + + ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_z ( + + + + angle : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation matrix containing the given 3D non-uniform `scale`. + + /// + + ///The resulting matrix can be used to transform 3D points and vectors. See + + ///[`Self::transform_point3()`] and [`Self::transform_vector3()`]. + + /// + + ///# Panics + + /// + + ///Will panic if all elements of `scale` are zero when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_scale ( + + + + #[proxy] + + scale : bevy::math::f64::DVec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the matrix column for the given `index`. + + /// + + ///# Panics + + /// + + ///Panics if `index` is greater than 3. + + #[lua( + + + + output(proxy), + + )] + fn col ( + + + &self, + + + + + index : usize, + + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + ///Returns the matrix row for the given `index`. + + /// + + ///# Panics + + /// + + ///Panics if `index` is greater than 3. + + #[lua( + + + + output(proxy), + + )] + fn row ( + + + &self, + + + + + index : usize, + + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + ///Returns `true` if, and only if, all elements are finite. + + ///If any element is either `NaN`, positive or negative infinity, this will return `false`. + + #[lua( + + + + )] + fn is_finite ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns `true` if any elements are `NaN`. + + #[lua( + + + + )] + fn is_nan ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns the transpose of `self`. + + #[lua( + + + + output(proxy), + + )] + fn transpose ( + + + &self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the determinant of `self`. + + #[lua( + + + + )] + fn determinant ( + + + &self, + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Returns the inverse of `self`. + + /// + + ///If the matrix is not invertible the returned matrix will be invalid. + + /// + + ///# Panics + + /// + + ///Will panic if the determinant of `self` is zero when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn inverse ( + + + &self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a left-handed view matrix using a camera position, an up direction, and a facing + + ///direction. + + /// + + ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn look_to_lh ( + + + + #[proxy] + + eye : bevy::math::f64::DVec3, + + + + + + #[proxy] + + dir : bevy::math::f64::DVec3, + + + + + + #[proxy] + + up : bevy::math::f64::DVec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a right-handed view matrix using a camera position, an up direction, and a facing + + ///direction. + + /// + + ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn look_to_rh ( + + + + #[proxy] + + eye : bevy::math::f64::DVec3, + + + + + + #[proxy] + + dir : bevy::math::f64::DVec3, + + + + + + #[proxy] + + up : bevy::math::f64::DVec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a left-handed view matrix using a camera position, an up direction, and a focal + + ///point. + + ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. + + /// + + ///# Panics + + /// + + ///Will panic if `up` is not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn look_at_lh ( + + + + #[proxy] + + eye : bevy::math::f64::DVec3, + + + + + + #[proxy] + + center : bevy::math::f64::DVec3, + + + + + + #[proxy] + + up : bevy::math::f64::DVec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a right-handed view matrix using a camera position, an up direction, and a focal + + ///point. + + ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. + + /// + + ///# Panics + + /// + + ///Will panic if `up` is not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn look_at_rh ( + + + + #[proxy] + + eye : bevy::math::f64::DVec3, + + + + + + #[proxy] + + center : bevy::math::f64::DVec3, + + + + + + #[proxy] + + up : bevy::math::f64::DVec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a right-handed perspective projection matrix with [-1,1] depth range. + + ///This is the same as the OpenGL `gluPerspective` function. + + ///See + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn perspective_rh_gl ( + + + + fov_y_radians : f64, + + + + + + aspect_ratio : f64, + + + + + + z_near : f64, + + + + + + z_far : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a left-handed perspective projection matrix with `[0,1]` depth range. + + /// + + ///# Panics + + /// + + ///Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is + + ///enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn perspective_lh ( + + + + fov_y_radians : f64, + + + + + + aspect_ratio : f64, + + + + + + z_near : f64, + + + + + + z_far : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a right-handed perspective projection matrix with `[0,1]` depth range. + + /// + + ///# Panics + + /// + + ///Will panic if `z_near` or `z_far` are less than or equal to zero when `glam_assert` is + + ///enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn perspective_rh ( + + + + fov_y_radians : f64, + + + + + + aspect_ratio : f64, + + + + + + z_near : f64, + + + + + + z_far : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an infinite left-handed perspective projection matrix with `[0,1]` depth range. + + /// + + ///# Panics + + /// + + ///Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn perspective_infinite_lh ( + + + + fov_y_radians : f64, + + + + + + aspect_ratio : f64, + + + + + + z_near : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an infinite left-handed perspective projection matrix with `[0,1]` depth range. + + /// + + ///# Panics + + /// + + ///Will panic if `z_near` is less than or equal to zero when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn perspective_infinite_reverse_lh ( + + + + fov_y_radians : f64, + + + + + + aspect_ratio : f64, + + + + + + z_near : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an infinite right-handed perspective projection matrix with + + ///`[0,1]` depth range. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn perspective_infinite_rh ( + + + + fov_y_radians : f64, + + + + + + aspect_ratio : f64, + + + + + + z_near : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an infinite reverse right-handed perspective projection matrix + + ///with `[0,1]` depth range. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn perspective_infinite_reverse_rh ( + + + + fov_y_radians : f64, + + + + + + aspect_ratio : f64, + + + + + + z_near : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a right-handed orthographic projection matrix with `[-1,1]` depth + + ///range. This is the same as the OpenGL `glOrtho` function in OpenGL. + + ///See + + /// + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn orthographic_rh_gl ( + + + + left : f64, + + + + + + right : f64, + + + + + + bottom : f64, + + + + + + top : f64, + + + + + + near : f64, + + + + + + far : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a left-handed orthographic projection matrix with `[0,1]` depth range. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn orthographic_lh ( + + + + left : f64, + + + + + + right : f64, + + + + + + bottom : f64, + + + + + + top : f64, + + + + + + near : f64, + + + + + + far : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a right-handed orthographic projection matrix with `[0,1]` depth range. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn orthographic_rh ( + + + + left : f64, + + + + + + right : f64, + + + + + + bottom : f64, + + + + + + top : f64, + + + + + + near : f64, + + + + + + far : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Transforms the given 3D vector as a point, applying perspective correction. + + /// + + ///This is the equivalent of multiplying the 3D vector as a 4D vector where `w` is `1.0`. + + ///The perspective divide is performed meaning the resulting 3D vector is divided by `w`. + + /// + + ///This method assumes that `self` contains a projective transform. + + #[lua( + + + + output(proxy), + + )] + fn project_point3 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f64::DVec3, + + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + ///Transforms the given 3D vector as a point. + + /// + + ///This is the equivalent of multiplying the 3D vector as a 4D vector where `w` is + + ///`1.0`. + + /// + + ///This method assumes that `self` contains a valid affine transform. It does not perform + + ///a persective divide, if `self` contains a perspective transform, or if you are unsure, + + ///the [`Self::project_point3()`] method should be used instead. + + /// + + ///# Panics + + /// + + ///Will panic if the 3rd row of `self` is not `(0, 0, 0, 1)` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn transform_point3 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f64::DVec3, + + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + ///Transforms the give 3D vector as a direction. + + /// + + ///This is the equivalent of multiplying the 3D vector as a 4D vector where `w` is + + ///`0.0`. + + /// + + ///This method assumes that `self` contains a valid affine transform. + + /// + + ///# Panics + + /// + + ///Will panic if the 3rd row of `self` is not `(0, 0, 0, 1)` when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn transform_vector3 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f64::DVec3, + + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + ///Transforms a 4D vector. + + #[lua( + + + + output(proxy), + + )] + fn mul_vec4 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f64::DVec4, + + + + ) + + + -> bevy::math::f64::DVec4 + + ; +"#, + r#" + + ///Multiplies a 4x4 matrix by a scalar. + + #[lua( + + + + output(proxy), + + )] + fn mul_scalar ( + + + &self, + + + + + rhs : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns true if the absolute difference of all elements between `self` and `rhs` + + ///is less than or equal to `max_abs_diff`. + + /// + + ///This can be used to compare if two matrices contain similar elements. It works best + + ///when comparing with a known value. The `max_abs_diff` that should be used used + + ///depends on the values being compared against. + + /// + + ///For more see + + ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua( + + + + )] + fn abs_diff_eq ( + + + &self, + + + + + #[proxy] + + rhs : Self, + + + + + + max_abs_diff : f64, + + + + ) + + + -> bool + + ; +"#, + r#" + + #[lua( + + + + output(proxy), + + )] + fn as_mat4 ( + + + &self, + + + ) + + + -> bevy::math::f32::Mat4 + + ; +"#, + ] +)] +pub struct DMat4; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::f32::Affine2", + functions[r#" + + ///Creates an affine transform from three column vectors. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_cols ( + + + + #[proxy] + + x_axis : bevy::math::f32::Vec2, + + + + + + #[proxy] + + y_axis : bevy::math::f32::Vec2, + + + + + + #[proxy] + + z_axis : bevy::math::f32::Vec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform that changes scale. + + ///Note that if any scale is zero the transform will be non-invertible. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_scale ( + + + + #[proxy] + + scale : bevy::math::f32::Vec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform from the given rotation `angle`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_angle ( + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation from the given 2D `translation`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_translation ( + + + + #[proxy] + + translation : bevy::math::f32::Vec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat2 ( + + + + #[proxy] + + matrix2 : bevy::math::f32::Mat2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) and a + + ///translation vector. + + /// + + ///Equivalent to + + ///`Affine2::from_translation(translation) * Affine2::from_mat2(mat2)` + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat2_translation ( + + + + #[proxy] + + matrix2 : bevy::math::f32::Mat2, + + + + + + #[proxy] + + translation : bevy::math::f32::Vec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform from the given 2D `scale`, rotation `angle` (in radians) and + + ///`translation`. + + /// + + ///Equivalent to `Affine2::from_translation(translation) * + + ///Affine2::from_angle(angle) * Affine2::from_scale(scale)` + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_scale_angle_translation ( + + + + #[proxy] + + scale : bevy::math::f32::Vec2, + + + + + + angle : f32, + + + + + + #[proxy] + + translation : bevy::math::f32::Vec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform from the given 2D rotation `angle` (in radians) and + + ///`translation`. + + /// + + ///Equivalent to `Affine2::from_translation(translation) * Affine2::from_angle(angle)` + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_angle_translation ( + + + + angle : f32, + + + + + + #[proxy] + + translation : bevy::math::f32::Vec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///The given `Mat3` must be an affine transform, + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat3 ( + + + + #[proxy] + + m : bevy::math::f32::Mat3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///The given [`Mat3A`] must be an affine transform, + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat3a ( + + + + #[proxy] + + m : bevy::math::f32::Mat3A, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Transforms the given 2D point, applying shear, scale, rotation and translation. + + #[lua( + + + + output(proxy), + + )] + fn transform_point2 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f32::Vec2, + + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + ///Transforms the given 2D vector, applying shear, scale and rotation (but NOT + + ///translation). + + /// + + ///To also apply translation, use [`Self::transform_point2()`] instead. + + #[lua( + + + + output(proxy), + + )] + fn transform_vector2 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f32::Vec2, + + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + ///Returns `true` if, and only if, all elements are finite. + + /// + + ///If any element is either `NaN`, positive or negative infinity, this will return + + ///`false`. + + #[lua( + + + + )] + fn is_finite ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns `true` if any elements are `NaN`. + + #[lua( + + + + )] + fn is_nan ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns true if the absolute difference of all elements between `self` and `rhs` + + ///is less than or equal to `max_abs_diff`. + + /// + + ///This can be used to compare if two 3x4 matrices contain similar elements. It works + + ///best when comparing with a known value. The `max_abs_diff` that should be used used + + ///depends on the values being compared against. + + /// + + ///For more see + + ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua( + + + + )] + fn abs_diff_eq ( + + + &self, + + + + + #[proxy] + + rhs : Self, + + + + + + max_abs_diff : f32, + + + + ) + + + -> bool + + ; +"#, + r#" + + ///Return the inverse of this transform. + + /// + + ///Note that if the transform is not invertible the result will be invalid. + + #[lua( + + + + output(proxy), + + )] + fn inverse ( + + + &self, + + + ) + + + -> Self + + ; +"#, + ] +)] +pub struct Affine2; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::f32::Affine3A", + functions[r#" + + ///Creates an affine transform from three column vectors. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_cols ( + + + + #[proxy] + + x_axis : bevy::math::f32::Vec3A, + + + + + + #[proxy] + + y_axis : bevy::math::f32::Vec3A, + + + + + + #[proxy] + + z_axis : bevy::math::f32::Vec3A, + + + + + + #[proxy] + + w_axis : bevy::math::f32::Vec3A, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform that changes scale. + + ///Note that if any scale is zero the transform will be non-invertible. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_scale ( + + + + #[proxy] + + scale : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform from the given `rotation` quaternion. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_quat ( + + + + #[proxy] + + rotation : bevy::math::f32::Quat, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform containing a 3D rotation around a normalized + + ///rotation `axis` of `angle` (in radians). + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_axis_angle ( + + + + #[proxy] + + axis : bevy::math::f32::Vec3, + + + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform containing a 3D rotation around the x axis of + + ///`angle` (in radians). + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_x ( + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform containing a 3D rotation around the y axis of + + ///`angle` (in radians). + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_y ( + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform containing a 3D rotation around the z axis of + + ///`angle` (in radians). + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_z ( + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation from the given 3D `translation`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_translation ( + + + + #[proxy] + + translation : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform from a 3x3 matrix (expressing scale, shear and + + ///rotation) + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat3 ( + + + + #[proxy] + + mat3 : bevy::math::f32::Mat3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform from a 3x3 matrix (expressing scale, shear and rotation) + + ///and a translation vector. + + /// + + ///Equivalent to `Affine3A::from_translation(translation) * Affine3A::from_mat3(mat3)` + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat3_translation ( + + + + #[proxy] + + mat3 : bevy::math::f32::Mat3, + + + + + + #[proxy] + + translation : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform from the given 3D `scale`, `rotation` and + + ///`translation`. + + /// + + ///Equivalent to `Affine3A::from_translation(translation) * + + ///Affine3A::from_quat(rotation) * Affine3A::from_scale(scale)` + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_scale_rotation_translation ( + + + + #[proxy] + + scale : bevy::math::f32::Vec3, + + + + + + #[proxy] + + rotation : bevy::math::f32::Quat, + + + + + + #[proxy] + + translation : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform from the given 3D `rotation` and `translation`. + + /// + + ///Equivalent to `Affine3A::from_translation(translation) * Affine3A::from_quat(rotation)` + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_translation ( + + + + #[proxy] + + rotation : bevy::math::f32::Quat, + + + + + + #[proxy] + + translation : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///The given `Mat4` must be an affine transform, + + ///i.e. contain no perspective transform. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat4 ( + + + + #[proxy] + + m : bevy::math::f32::Mat4, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a left-handed view transform using a camera position, an up direction, and a facing + + ///direction. + + /// + + ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn look_to_lh ( + + + + #[proxy] + + eye : bevy::math::f32::Vec3, + + + + + + #[proxy] + + dir : bevy::math::f32::Vec3, + + + + + + #[proxy] + + up : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a right-handed view transform using a camera position, an up direction, and a facing + + ///direction. + + /// + + ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn look_to_rh ( + + + + #[proxy] + + eye : bevy::math::f32::Vec3, + + + + + + #[proxy] + + dir : bevy::math::f32::Vec3, + + + + + + #[proxy] + + up : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a left-handed view transform using a camera position, an up direction, and a focal + + ///point. + + ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. + + /// + + ///# Panics + + /// + + ///Will panic if `up` is not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn look_at_lh ( + + + + #[proxy] + + eye : bevy::math::f32::Vec3, + + + + + + #[proxy] + + center : bevy::math::f32::Vec3, + + + + + + #[proxy] + + up : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a right-handed view transform using a camera position, an up direction, and a focal + + ///point. + + ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. + + /// + + ///# Panics + + /// + + ///Will panic if `up` is not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn look_at_rh ( + + + + #[proxy] + + eye : bevy::math::f32::Vec3, + + + + + + #[proxy] + + center : bevy::math::f32::Vec3, + + + + + + #[proxy] + + up : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Transforms the given 3D points, applying shear, scale, rotation and translation. + + #[lua( + + + + output(proxy), + + )] + fn transform_point3 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f32::Vec3, + + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Transforms the given 3D vector, applying shear, scale and rotation (but NOT + + ///translation). + + /// + + ///To also apply translation, use [`Self::transform_point3()`] instead. + + #[lua( + + + + output(proxy), + + )] + fn transform_vector3 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f32::Vec3, + + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Transforms the given [`Vec3A`], applying shear, scale, rotation and translation. + + #[lua( + + + + output(proxy), + + )] + fn transform_point3a ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f32::Vec3A, + + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + ///Transforms the given [`Vec3A`], applying shear, scale and rotation (but NOT + + ///translation). + + /// + + ///To also apply translation, use [`Self::transform_point3a()`] instead. + + #[lua( + + + + output(proxy), + + )] + fn transform_vector3a ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f32::Vec3A, + + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + ///Returns `true` if, and only if, all elements are finite. + + /// + + ///If any element is either `NaN`, positive or negative infinity, this will return + + ///`false`. + + #[lua( + + + + )] + fn is_finite ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns `true` if any elements are `NaN`. + + #[lua( + + + + )] + fn is_nan ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns true if the absolute difference of all elements between `self` and `rhs` + + ///is less than or equal to `max_abs_diff`. + + /// + + ///This can be used to compare if two 3x4 matrices contain similar elements. It works + + ///best when comparing with a known value. The `max_abs_diff` that should be used used + + ///depends on the values being compared against. + + /// + + ///For more see + + ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua( + + + + )] + fn abs_diff_eq ( + + + &self, + + + + + #[proxy] + + rhs : Self, + + + + + + max_abs_diff : f32, + + + + ) + + + -> bool + + ; +"#, + r#" + + ///Return the inverse of this transform. + + /// + + ///Note that if the transform is not invertible the result will be invalid. + + #[lua( + + + + output(proxy), + + )] + fn inverse ( + + + &self, + + + ) + + + -> Self + + ; +"#, + ] +)] +pub struct Affine3A; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::f64::DAffine2", + functions[r#" + + ///Creates an affine transform from three column vectors. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_cols ( + + + + #[proxy] + + x_axis : bevy::math::f64::DVec2, + + + + + + #[proxy] + + y_axis : bevy::math::f64::DVec2, + + + + + + #[proxy] + + z_axis : bevy::math::f64::DVec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform that changes scale. + + ///Note that if any scale is zero the transform will be non-invertible. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_scale ( + + + + #[proxy] + + scale : bevy::math::f64::DVec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform from the given rotation `angle`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_angle ( + + + + angle : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation from the given 2D `translation`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_translation ( + + + + #[proxy] + + translation : bevy::math::f64::DVec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat2 ( + + + + #[proxy] + + matrix2 : bevy::math::f64::DMat2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform from a 2x2 matrix (expressing scale, shear and rotation) and a + + ///translation vector. + + /// + + ///Equivalent to + + ///`DAffine2::from_translation(translation) * DAffine2::from_mat2(mat2)` + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat2_translation ( + + + + #[proxy] + + matrix2 : bevy::math::f64::DMat2, + + + + + + #[proxy] + + translation : bevy::math::f64::DVec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform from the given 2D `scale`, rotation `angle` (in radians) and + + ///`translation`. + + /// + + ///Equivalent to `DAffine2::from_translation(translation) * + + ///DAffine2::from_angle(angle) * DAffine2::from_scale(scale)` + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_scale_angle_translation ( + + + + #[proxy] + + scale : bevy::math::f64::DVec2, + + + + + + angle : f64, + + + + + + #[proxy] + + translation : bevy::math::f64::DVec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform from the given 2D rotation `angle` (in radians) and + + ///`translation`. + + /// + + ///Equivalent to `DAffine2::from_translation(translation) * DAffine2::from_angle(angle)` + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_angle_translation ( + + + + angle : f64, + + + + + + #[proxy] + + translation : bevy::math::f64::DVec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///The given `DMat3` must be an affine transform, + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat3 ( + + + + #[proxy] + + m : bevy::math::f64::DMat3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Transforms the given 2D point, applying shear, scale, rotation and translation. + + #[lua( + + + + output(proxy), + + )] + fn transform_point2 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f64::DVec2, + + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + ///Transforms the given 2D vector, applying shear, scale and rotation (but NOT + + ///translation). + + /// + + ///To also apply translation, use [`Self::transform_point2()`] instead. + + #[lua( + + + + output(proxy), + + )] + fn transform_vector2 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f64::DVec2, + + + + ) + + + -> bevy::math::f64::DVec2 + + ; +"#, + r#" + + ///Returns `true` if, and only if, all elements are finite. + + /// + + ///If any element is either `NaN`, positive or negative infinity, this will return + + ///`false`. + + #[lua( + + + + )] + fn is_finite ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns `true` if any elements are `NaN`. + + #[lua( + + + + )] + fn is_nan ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns true if the absolute difference of all elements between `self` and `rhs` + + ///is less than or equal to `max_abs_diff`. + + /// + + ///This can be used to compare if two 3x4 matrices contain similar elements. It works + + ///best when comparing with a known value. The `max_abs_diff` that should be used used + + ///depends on the values being compared against. + + /// + + ///For more see + + ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua( + + + + )] + fn abs_diff_eq ( + + + &self, + + + + + #[proxy] + + rhs : Self, + + + + + + max_abs_diff : f64, + + + + ) + + + -> bool + + ; +"#, + r#" + + ///Return the inverse of this transform. + + /// + + ///Note that if the transform is not invertible the result will be invalid. + + #[lua( + + + + output(proxy), + + )] + fn inverse ( + + + &self, + + + ) + + + -> Self + + ; +"#, + ] +)] +pub struct DAffine2; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::f64::DAffine3", + functions[r#" + + ///Creates an affine transform from three column vectors. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_cols ( + + + + #[proxy] + + x_axis : bevy::math::f64::DVec3, + + + + + + #[proxy] + + y_axis : bevy::math::f64::DVec3, + + + + + + #[proxy] + + z_axis : bevy::math::f64::DVec3, + + + + + + #[proxy] + + w_axis : bevy::math::f64::DVec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform that changes scale. + + ///Note that if any scale is zero the transform will be non-invertible. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_scale ( + + + + #[proxy] + + scale : bevy::math::f64::DVec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform from the given `rotation` quaternion. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_quat ( + + + + #[proxy] + + rotation : bevy::math::f64::DQuat, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform containing a 3D rotation around a normalized + + ///rotation `axis` of `angle` (in radians). + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_axis_angle ( + + + + #[proxy] + + axis : bevy::math::f64::DVec3, + + + + + + angle : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform containing a 3D rotation around the x axis of + + ///`angle` (in radians). + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_x ( + + + + angle : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform containing a 3D rotation around the y axis of + + ///`angle` (in radians). + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_y ( + + + + angle : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform containing a 3D rotation around the z axis of + + ///`angle` (in radians). + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_z ( + + + + angle : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transformation from the given 3D `translation`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_translation ( + + + + #[proxy] + + translation : bevy::math::f64::DVec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform from a 3x3 matrix (expressing scale, shear and + + ///rotation) + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat3 ( + + + + #[proxy] + + mat3 : bevy::math::f64::DMat3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform from a 3x3 matrix (expressing scale, shear and rotation) + + ///and a translation vector. + + /// + + ///Equivalent to `DAffine3::from_translation(translation) * DAffine3::from_mat3(mat3)` + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat3_translation ( + + + + #[proxy] + + mat3 : bevy::math::f64::DMat3, + + + + + + #[proxy] + + translation : bevy::math::f64::DVec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform from the given 3D `scale`, `rotation` and + + ///`translation`. + + /// + + ///Equivalent to `DAffine3::from_translation(translation) * + + ///DAffine3::from_quat(rotation) * DAffine3::from_scale(scale)` + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_scale_rotation_translation ( + + + + #[proxy] + + scale : bevy::math::f64::DVec3, + + + + + + #[proxy] + + rotation : bevy::math::f64::DQuat, + + + + + + #[proxy] + + translation : bevy::math::f64::DVec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates an affine transform from the given 3D `rotation` and `translation`. + + /// + + ///Equivalent to `DAffine3::from_translation(translation) * DAffine3::from_quat(rotation)` + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_translation ( + + + + #[proxy] + + rotation : bevy::math::f64::DQuat, + + + + + + #[proxy] + + translation : bevy::math::f64::DVec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///The given `DMat4` must be an affine transform, + + ///i.e. contain no perspective transform. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat4 ( + + + + #[proxy] + + m : bevy::math::f64::DMat4, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a left-handed view transform using a camera position, an up direction, and a facing + + ///direction. + + /// + + ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn look_to_lh ( + + + + #[proxy] + + eye : bevy::math::f64::DVec3, + + + + + + #[proxy] + + dir : bevy::math::f64::DVec3, + + + + + + #[proxy] + + up : bevy::math::f64::DVec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a right-handed view transform using a camera position, an up direction, and a facing + + ///direction. + + /// + + ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn look_to_rh ( + + + + #[proxy] + + eye : bevy::math::f64::DVec3, + + + + + + #[proxy] + + dir : bevy::math::f64::DVec3, + + + + + + #[proxy] + + up : bevy::math::f64::DVec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a left-handed view transform using a camera position, an up direction, and a focal + + ///point. + + ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=forward`. + + /// + + ///# Panics + + /// + + ///Will panic if `up` is not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn look_at_lh ( + + + + #[proxy] + + eye : bevy::math::f64::DVec3, + + + + + + #[proxy] + + center : bevy::math::f64::DVec3, + + + + + + #[proxy] + + up : bevy::math::f64::DVec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a right-handed view transform using a camera position, an up direction, and a focal + + ///point. + + ///For a view coordinate system with `+X=right`, `+Y=up` and `+Z=back`. + + /// + + ///# Panics + + /// + + ///Will panic if `up` is not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn look_at_rh ( + + + + #[proxy] + + eye : bevy::math::f64::DVec3, + + + + + + #[proxy] + + center : bevy::math::f64::DVec3, + + + + + + #[proxy] + + up : bevy::math::f64::DVec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Transforms the given 3D points, applying shear, scale, rotation and translation. + + #[lua( + + + + output(proxy), + + )] + fn transform_point3 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f64::DVec3, + + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + ///Transforms the given 3D vector, applying shear, scale and rotation (but NOT + + ///translation). + + /// + + ///To also apply translation, use [`Self::transform_point3()`] instead. + + #[lua( + + + + output(proxy), + + )] + fn transform_vector3 ( + + + &self, + + + + + #[proxy] + + rhs : bevy::math::f64::DVec3, + + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + ///Returns `true` if, and only if, all elements are finite. + + /// + + ///If any element is either `NaN`, positive or negative infinity, this will return + + ///`false`. + + #[lua( + + + + )] + fn is_finite ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns `true` if any elements are `NaN`. + + #[lua( + + + + )] + fn is_nan ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns true if the absolute difference of all elements between `self` and `rhs` + + ///is less than or equal to `max_abs_diff`. + + /// + + ///This can be used to compare if two 3x4 matrices contain similar elements. It works + + ///best when comparing with a known value. The `max_abs_diff` that should be used used + + ///depends on the values being compared against. + + /// + + ///For more see + + ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua( + + + + )] + fn abs_diff_eq ( + + + &self, + + + + + #[proxy] + + rhs : Self, + + + + + + max_abs_diff : f64, + + + + ) + + + -> bool + + ; +"#, + r#" + + ///Return the inverse of this transform. + + /// + + ///Note that if the transform is not invertible the result will be invalid. + + #[lua( + + + + output(proxy), + + )] + fn inverse ( + + + &self, + + + ) + + + -> Self + + ; +"#, + ] +)] +pub struct DAffine3; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::f32::Quat", + functions[r#" + + ///Creates a new rotation quaternion. + + /// + + ///This should generally not be called manually unless you know what you are doing. + + ///Use one of the other constructors instead such as `identity` or `from_axis_angle`. + + /// + + ///`from_xyzw` is mostly used by unit tests and `serde` deserialization. + + /// + + ///# Preconditions + + /// + + ///This function does not check if the input is normalized, it is up to the user to + + ///provide normalized input or to normalized the resulting quaternion. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_xyzw ( + + + + x : f32, + + + + + + y : f32, + + + + + + z : f32, + + + + + + w : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a new rotation quaternion from a 4D vector. + + /// + + ///# Preconditions + + /// + + ///This function does not check if the input is normalized, it is up to the user to + + ///provide normalized input or to normalized the resulting quaternion. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_vec4 ( + + + + #[proxy] + + v : bevy::math::f32::Vec4, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Create a quaternion for a normalized rotation `axis` and `angle` (in radians). + + /// + + ///The axis must be a unit vector. + + /// + + ///# Panics + + /// + + ///Will panic if `axis` is not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_axis_angle ( + + + + #[proxy] + + axis : bevy::math::f32::Vec3, + + + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Create a quaternion that rotates `v.length()` radians around `v.normalize()`. + + /// + + ///`from_scaled_axis(Vec3::ZERO)` results in the identity quaternion. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_scaled_axis ( + + + + #[proxy] + + v : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a quaternion from the `angle` (in radians) around the x axis. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_x ( + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a quaternion from the `angle` (in radians) around the y axis. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_y ( + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a quaternion from the `angle` (in radians) around the z axis. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_z ( + + + + angle : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a quaternion from the given Euler rotation sequence and the angles (in radians). + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_euler ( + + + + #[proxy] + + euler : bevy::math::EulerRot, + + + + + + a : f32, + + + + + + b : f32, + + + + + + c : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a quaternion from a 3x3 rotation matrix. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat3 ( + + + + #[proxy] + + mat : &bevy::math::f32::Mat3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a quaternion from a 3x3 SIMD aligned rotation matrix. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat3a ( + + + + #[proxy] + + mat : &bevy::math::f32::Mat3A, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a quaternion from a 3x3 rotation matrix inside a homogeneous 4x4 matrix. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat4 ( + + + + #[proxy] + + mat : &bevy::math::f32::Mat4, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Gets the minimal rotation for transforming `from` to `to`. The rotation is in the + + ///plane spanned by the two vectors. Will rotate at most 180 degrees. + + /// + + ///The inputs must be unit vectors. + + /// + + ///`from_rotation_arc(from, to) * from ≈ to`. + + /// + + ///For near-singular cases (from≈to and from≈-to) the current implementation + + ///is only accurate to about 0.001 (for `f32`). + + /// + + ///# Panics + + /// + + ///Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_arc ( + + + + #[proxy] + + from : bevy::math::f32::Vec3, + + + + + + #[proxy] + + to : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Gets the minimal rotation for transforming `from` to either `to` or `-to`. This means + + ///that the resulting quaternion will rotate `from` so that it is colinear with `to`. + + /// + + ///The rotation is in the plane spanned by the two vectors. Will rotate at most 90 + + ///degrees. + + /// + + ///The inputs must be unit vectors. + + /// + + ///`to.dot(from_rotation_arc_colinear(from, to) * from).abs() ≈ 1`. + + /// + + ///# Panics + + /// + + ///Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_arc_colinear ( + + + + #[proxy] + + from : bevy::math::f32::Vec3, + + + + + + #[proxy] + + to : bevy::math::f32::Vec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Gets the minimal rotation for transforming `from` to `to`. The resulting rotation is + + ///around the z axis. Will rotate at most 180 degrees. + + /// + + ///The inputs must be unit vectors. + + /// + + ///`from_rotation_arc_2d(from, to) * from ≈ to`. + + /// + + ///For near-singular cases (from≈to and from≈-to) the current implementation + + ///is only accurate to about 0.001 (for `f32`). + + /// + + ///# Panics + + /// + + ///Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_arc_2d ( + + + + #[proxy] + + from : bevy::math::f32::Vec2, + + + + + + #[proxy] + + to : bevy::math::f32::Vec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the rotation axis scaled by the rotation in radians. + + #[lua( + + + + output(proxy), + + )] + fn to_scaled_axis ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Returns the vector part of the quaternion. + + #[lua( + + + + output(proxy), + + )] + fn xyz ( + + + self, + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Returns the quaternion conjugate of `self`. For a unit quaternion the + + ///conjugate is also the inverse. + + #[lua( + + + + output(proxy), + + )] + fn conjugate ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the inverse of a normalized quaternion. + + /// + + ///Typically quaternion inverse returns the conjugate of a normalized quaternion. + + ///Because `self` is assumed to already be unit length this method *does not* normalize + + ///before returning the conjugate. + + /// + + ///# Panics + + /// + + ///Will panic if `self` is not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn inverse ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Computes the dot product of `self` and `rhs`. The dot product is + + ///equal to the cosine of the angle between two quaternion rotations. + + #[lua( + + + + )] + fn dot ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Computes the length of `self`. + + #[lua( + + + + )] + fn length ( + + + self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Computes the squared length of `self`. + + /// + + ///This is generally faster than `length()` as it avoids a square + + ///root operation. + + #[lua( + + + + )] + fn length_squared ( + + + self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Computes `1.0 / length()`. + + /// + + ///For valid results, `self` must _not_ be of length zero. + + #[lua( + + + + )] + fn length_recip ( + + + self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns `self` normalized to length 1.0. + + /// + + ///For valid results, `self` must _not_ be of length zero. + + /// + + ///Panics + + /// + + ///Will panic if `self` is zero length when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn normalize ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns `true` if, and only if, all elements are finite. + + ///If any element is either `NaN`, positive or negative infinity, this will return `false`. + + #[lua( + + + + )] + fn is_finite ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + #[lua( + + + + )] + fn is_nan ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns whether `self` of length `1.0` or not. + + /// + + ///Uses a precision threshold of `1e-6`. + + #[lua( + + + + )] + fn is_normalized ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + #[lua( + + + + )] + fn is_near_identity ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns the angle (in radians) for the minimal rotation + + ///for transforming this quaternion into another. + + /// + + ///Both quaternions must be normalized. + + /// + + ///# Panics + + /// + + ///Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. + + #[lua( + + + + )] + fn angle_between ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Returns true if the absolute difference of all elements between `self` and `rhs` + + ///is less than or equal to `max_abs_diff`. + + /// + + ///This can be used to compare if two quaternions contain similar elements. It works + + ///best when comparing with a known value. The `max_abs_diff` that should be used used + + ///depends on the values being compared against. + + /// + + ///For more see + + ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua( + + + + )] + fn abs_diff_eq ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + + + max_abs_diff : f32, + + + + ) + + + -> bool + + ; +"#, + r#" + + ///Performs a linear interpolation between `self` and `rhs` based on + + ///the value `s`. + + /// + + ///When `s` is `0.0`, the result will be equal to `self`. When `s` + + ///is `1.0`, the result will be equal to `rhs`. + + /// + + ///# Panics + + /// + + ///Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn lerp ( + + + self, + + + + + #[proxy] + + end : Self, + + + + + + s : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Performs a spherical linear interpolation between `self` and `end` + + ///based on the value `s`. + + /// + + ///When `s` is `0.0`, the result will be equal to `self`. When `s` + + ///is `1.0`, the result will be equal to `end`. + + /// + + ///# Panics + + /// + + ///Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn slerp ( + + + self, + + + + + #[proxy] + + end : Self, + + + + + + s : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Multiplies a quaternion and a 3D vector, returning the rotated vector. + + /// + + ///# Panics + + /// + + ///Will panic if `self` is not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn mul_vec3 ( + + + self, + + + + + #[proxy] + + rhs : bevy::math::f32::Vec3, + + + + ) + + + -> bevy::math::f32::Vec3 + + ; +"#, + r#" + + ///Multiplies two quaternions. If they each represent a rotation, the result will + + ///represent the combined rotation. + + /// + + ///Note that due to floating point rounding the result may not be perfectly normalized. + + /// + + ///# Panics + + /// + + ///Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn mul_quat ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_affine3 ( + + + + #[proxy] + + a : &bevy::math::f32::Affine3A, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Multiplies a quaternion and a 3D vector, returning the rotated vector. + + #[lua( + + + + output(proxy), + + )] + fn mul_vec3a ( + + + self, + + + + + #[proxy] + + rhs : bevy::math::f32::Vec3A, + + + + ) + + + -> bevy::math::f32::Vec3A + + ; +"#, + r#" + + #[lua( + + + + output(proxy), + + )] + fn as_f64 ( + + + self, + + + ) + + + -> bevy::math::f64::DQuat + + ; +"#, + ] +)] +pub struct Quat; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::f64::DQuat", + functions[r#" + + ///Creates a new rotation quaternion. + + /// + + ///This should generally not be called manually unless you know what you are doing. + + ///Use one of the other constructors instead such as `identity` or `from_axis_angle`. + + /// + + ///`from_xyzw` is mostly used by unit tests and `serde` deserialization. + + /// + + ///# Preconditions + + /// + + ///This function does not check if the input is normalized, it is up to the user to + + ///provide normalized input or to normalized the resulting quaternion. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_xyzw ( + + + + x : f64, + + + + + + y : f64, + + + + + + z : f64, + + + + + + w : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a new rotation quaternion from a 4D vector. + + /// + + ///# Preconditions + + /// + + ///This function does not check if the input is normalized, it is up to the user to + + ///provide normalized input or to normalized the resulting quaternion. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_vec4 ( + + + + #[proxy] + + v : bevy::math::f64::DVec4, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Create a quaternion for a normalized rotation `axis` and `angle` (in radians). + + /// + + ///The axis must be a unit vector. + + /// + + ///# Panics + + /// + + ///Will panic if `axis` is not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_axis_angle ( + + + + #[proxy] + + axis : bevy::math::f64::DVec3, + + + + + + angle : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Create a quaternion that rotates `v.length()` radians around `v.normalize()`. + + /// + + ///`from_scaled_axis(Vec3::ZERO)` results in the identity quaternion. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_scaled_axis ( + + + + #[proxy] + + v : bevy::math::f64::DVec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a quaternion from the `angle` (in radians) around the x axis. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_x ( + + + + angle : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a quaternion from the `angle` (in radians) around the y axis. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_y ( + + + + angle : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a quaternion from the `angle` (in radians) around the z axis. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_z ( + + + + angle : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a quaternion from the given Euler rotation sequence and the angles (in radians). + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_euler ( + + + + #[proxy] + + euler : bevy::math::EulerRot, + + + + + + a : f64, + + + + + + b : f64, + + + + + + c : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a quaternion from a 3x3 rotation matrix. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat3 ( + + + + #[proxy] + + mat : &bevy::math::f64::DMat3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a quaternion from a 3x3 rotation matrix inside a homogeneous 4x4 matrix. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_mat4 ( + + + + #[proxy] + + mat : &bevy::math::f64::DMat4, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Gets the minimal rotation for transforming `from` to `to`. The rotation is in the + + ///plane spanned by the two vectors. Will rotate at most 180 degrees. + + /// + + ///The inputs must be unit vectors. + + /// + + ///`from_rotation_arc(from, to) * from ≈ to`. + + /// + + ///For near-singular cases (from≈to and from≈-to) the current implementation + + ///is only accurate to about 0.001 (for `f32`). + + /// + + ///# Panics + + /// + + ///Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_arc ( + + + + #[proxy] + + from : bevy::math::f64::DVec3, + + + + + + #[proxy] + + to : bevy::math::f64::DVec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Gets the minimal rotation for transforming `from` to either `to` or `-to`. This means + + ///that the resulting quaternion will rotate `from` so that it is colinear with `to`. + + /// + + ///The rotation is in the plane spanned by the two vectors. Will rotate at most 90 + + ///degrees. + + /// + + ///The inputs must be unit vectors. + + /// + + ///`to.dot(from_rotation_arc_colinear(from, to) * from).abs() ≈ 1`. + + /// + + ///# Panics + + /// + + ///Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_arc_colinear ( + + + + #[proxy] + + from : bevy::math::f64::DVec3, + + + + + + #[proxy] + + to : bevy::math::f64::DVec3, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Gets the minimal rotation for transforming `from` to `to`. The resulting rotation is + + ///around the z axis. Will rotate at most 180 degrees. + + /// + + ///The inputs must be unit vectors. + + /// + + ///`from_rotation_arc_2d(from, to) * from ≈ to`. + + /// + + ///For near-singular cases (from≈to and from≈-to) the current implementation + + ///is only accurate to about 0.001 (for `f32`). + + /// + + ///# Panics + + /// + + ///Will panic if `from` or `to` are not normalized when `glam_assert` is enabled. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_rotation_arc_2d ( + + + + #[proxy] + + from : bevy::math::f64::DVec2, + + + + + + #[proxy] + + to : bevy::math::f64::DVec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the rotation axis scaled by the rotation in radians. + + #[lua( + + + + output(proxy), + + )] + fn to_scaled_axis ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + ///Returns the vector part of the quaternion. + + #[lua( + + + + output(proxy), + + )] + fn xyz ( + + + self, + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + ///Returns the quaternion conjugate of `self`. For a unit quaternion the + + ///conjugate is also the inverse. + + #[lua( + + + + output(proxy), + + )] + fn conjugate ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns the inverse of a normalized quaternion. + + /// + + ///Typically quaternion inverse returns the conjugate of a normalized quaternion. + + ///Because `self` is assumed to already be unit length this method *does not* normalize + + ///before returning the conjugate. + + /// + + ///# Panics + + /// + + ///Will panic if `self` is not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn inverse ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Computes the dot product of `self` and `rhs`. The dot product is + + ///equal to the cosine of the angle between two quaternion rotations. + + #[lua( + + + + )] + fn dot ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Computes the length of `self`. + + #[lua( + + + + )] + fn length ( + + + self, + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Computes the squared length of `self`. + + /// + + ///This is generally faster than `length()` as it avoids a square + + ///root operation. + + #[lua( + + + + )] + fn length_squared ( + + + self, + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Computes `1.0 / length()`. + + /// + + ///For valid results, `self` must _not_ be of length zero. + + #[lua( + + + + )] + fn length_recip ( + + + self, + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Returns `self` normalized to length 1.0. + + /// + + ///For valid results, `self` must _not_ be of length zero. + + /// + + ///Panics + + /// + + ///Will panic if `self` is zero length when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn normalize ( + + + self, + + + ) + + + -> Self + + ; +"#, + r#" + + ///Returns `true` if, and only if, all elements are finite. + + ///If any element is either `NaN`, positive or negative infinity, this will return `false`. + + #[lua( + + + + )] + fn is_finite ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + #[lua( + + + + )] + fn is_nan ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns whether `self` of length `1.0` or not. + + /// + + ///Uses a precision threshold of `1e-6`. + + #[lua( + + + + )] + fn is_normalized ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + #[lua( + + + + )] + fn is_near_identity ( + + + self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Returns the angle (in radians) for the minimal rotation + + ///for transforming this quaternion into another. + + /// + + ///Both quaternions must be normalized. + + /// + + ///# Panics + + /// + + ///Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. + + #[lua( + + + + )] + fn angle_between ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> f64 + + ; +"#, + r#" + + ///Returns true if the absolute difference of all elements between `self` and `rhs` + + ///is less than or equal to `max_abs_diff`. + + /// + + ///This can be used to compare if two quaternions contain similar elements. It works + + ///best when comparing with a known value. The `max_abs_diff` that should be used used + + ///depends on the values being compared against. + + /// + + ///For more see + + ///[comparing floating point numbers](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/). + + #[lua( + + + + )] + fn abs_diff_eq ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + + + max_abs_diff : f64, + + + + ) + + + -> bool + + ; +"#, + r#" + + ///Performs a linear interpolation between `self` and `rhs` based on + + ///the value `s`. + + /// + + ///When `s` is `0.0`, the result will be equal to `self`. When `s` + + ///is `1.0`, the result will be equal to `rhs`. + + /// + + ///# Panics + + /// + + ///Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn lerp ( + + + self, + + + + + #[proxy] + + end : Self, + + + + + + s : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Performs a spherical linear interpolation between `self` and `end` + + ///based on the value `s`. + + /// + + ///When `s` is `0.0`, the result will be equal to `self`. When `s` + + ///is `1.0`, the result will be equal to `end`. + + /// + + ///# Panics + + /// + + ///Will panic if `self` or `end` are not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn slerp ( + + + self, + + + + + #[proxy] + + end : Self, + + + + + + s : f64, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Multiplies a quaternion and a 3D vector, returning the rotated vector. + + /// + + ///# Panics + + /// + + ///Will panic if `self` is not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn mul_vec3 ( + + + self, + + + + + #[proxy] + + rhs : bevy::math::f64::DVec3, + + + + ) + + + -> bevy::math::f64::DVec3 + + ; +"#, + r#" + + ///Multiplies two quaternions. If they each represent a rotation, the result will + + ///represent the combined rotation. + + /// + + ///Note that due to floating point rounding the result may not be perfectly normalized. + + /// + + ///# Panics + + /// + + ///Will panic if `self` or `rhs` are not normalized when `glam_assert` is enabled. + + #[lua( + + + + output(proxy), + + )] + fn mul_quat ( + + + self, + + + + + #[proxy] + + rhs : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Creates a quaternion from a 3x3 rotation matrix inside a 3D affine transform. + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_affine3 ( + + + + #[proxy] + + a : &bevy::math::f64::DAffine3, + + + + ) + + + -> Self + + ; +"#, + r#" + + #[lua( + + + + output(proxy), + + )] + fn as_f32 ( + + + self, + + + ) + + + -> bevy::math::f32::Quat + + ; +"#, + ] +)] +pub struct DQuat; +#[derive(LuaProxy)] +#[proxy(derive(clone, debug), remote = "bevy::math::EulerRot", functions[])] +pub struct EulerRot; +#[derive(LuaProxy)] +#[proxy( + derive(clone, debug), + remote = "bevy::math::Rect", + functions[r#" + + ///Create a new rectangle from two corner points. + + /// + + ///The two points do not need to be the minimum and/or maximum corners. + + ///They only need to be two opposite corners. + + /// + + ///# Examples + + /// + + ///```rust + + ///# use bevy_math::Rect; + + ///let r = Rect::new(0., 4., 10., 6.); // w=10 h=2 + + ///let r = Rect::new(2., 3., 5., -1.); // w=3 h=4 + + ///``` + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn new ( + + + + x0 : f32, + + + + + + y0 : f32, + + + + + + x1 : f32, + + + + + + y1 : f32, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Create a new rectangle from two corner points. + + /// + + ///The two points do not need to be the minimum and/or maximum corners. + + ///They only need to be two opposite corners. + + /// + + ///# Examples + + /// + + ///```rust + + ///# use bevy_math::{Rect, Vec2}; + + ///// Unit rect from [0,0] to [1,1] + + ///let r = Rect::from_corners(Vec2::ZERO, Vec2::ONE); // w=1 h=1 + + ///// Same; the points do not need to be ordered + + ///let r = Rect::from_corners(Vec2::ONE, Vec2::ZERO); // w=1 h=1 + + ///``` + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_corners ( + + + + #[proxy] + + p0 : bevy::math::f32::Vec2, + + + + + + #[proxy] + + p1 : bevy::math::f32::Vec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Create a new rectangle from its center and size. + + /// + + ///# Panics + + /// + + ///This method panics if any of the components of the size is negative. + + /// + + ///# Examples + + /// + + ///```rust + + ///# use bevy_math::{Rect, Vec2}; + + ///let r = Rect::from_center_size(Vec2::ZERO, Vec2::ONE); // w=1 h=1 + + ///assert!(r.min.abs_diff_eq(Vec2::splat(-0.5), 1e-5)); + + ///assert!(r.max.abs_diff_eq(Vec2::splat(0.5), 1e-5)); + + ///``` + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_center_size ( + + + + #[proxy] + + origin : bevy::math::f32::Vec2, + + + + + + #[proxy] + + size : bevy::math::f32::Vec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Create a new rectangle from its center and half-size. + + /// + + ///# Panics + + /// + + ///This method panics if any of the components of the half-size is negative. + + /// + + ///# Examples + + /// + + ///```rust + + ///# use bevy_math::{Rect, Vec2}; + + ///let r = Rect::from_center_half_size(Vec2::ZERO, Vec2::ONE); // w=2 h=2 + + ///assert!(r.min.abs_diff_eq(Vec2::splat(-1.), 1e-5)); + + ///assert!(r.max.abs_diff_eq(Vec2::splat(1.), 1e-5)); + + ///``` + + #[lua( + + kind="function", + + + + output(proxy), + + )] + fn from_center_half_size ( + + + + #[proxy] + + origin : bevy::math::f32::Vec2, + + + + + + #[proxy] + + half_size : bevy::math::f32::Vec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Check if the rectangle is empty. + + /// + + ///# Examples + + /// + + ///```rust + + ///# use bevy_math::{Rect, Vec2}; + + ///let r = Rect::from_corners(Vec2::ZERO, Vec2::new(0., 1.)); // w=0 h=1 + + ///assert!(r.is_empty()); + + ///``` + + #[lua( + + + + )] + fn is_empty ( + + + &self, + + + ) + + + -> bool + + ; +"#, + r#" + + ///Rectangle width (max.x - min.x). + + /// + + ///# Examples + + /// + + ///```rust + + ///# use bevy_math::Rect; + + ///let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 + + ///assert!((r.width() - 5.).abs() <= 1e-5); + + ///``` + + #[lua( + + + + )] + fn width ( + + + &self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Rectangle height (max.y - min.y). + + /// + + ///# Examples + + /// + + ///```rust + + ///# use bevy_math::Rect; + + ///let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 + + ///assert!((r.height() - 1.).abs() <= 1e-5); + + ///``` + + #[lua( + + + + )] + fn height ( + + + &self, + + + ) + + + -> f32 + + ; +"#, + r#" + + ///Rectangle size. + + /// + + ///# Examples + + /// + + ///```rust + + ///# use bevy_math::{Rect, Vec2}; + + ///let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 + + ///assert!(r.size().abs_diff_eq(Vec2::new(5., 1.), 1e-5)); + + ///``` + + #[lua( + + + + output(proxy), + + )] + fn size ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + ///Rectangle half-size. + + /// + + ///# Examples + + /// + + ///```rust + + ///# use bevy_math::{Rect, Vec2}; + + ///let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 + + ///assert!(r.half_size().abs_diff_eq(Vec2::new(2.5, 0.5), 1e-5)); + + ///``` + + #[lua( + + + + output(proxy), + + )] + fn half_size ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + ///The center point of the rectangle. + + /// + + ///# Examples + + /// + + ///```rust + + ///# use bevy_math::{Rect, Vec2}; + + ///let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 + + ///assert!(r.center().abs_diff_eq(Vec2::new(2.5, 0.5), 1e-5)); + + ///``` + + #[lua( + + + + output(proxy), + + )] + fn center ( + + + &self, + + + ) + + + -> bevy::math::f32::Vec2 + + ; +"#, + r#" + + ///Check if a point lies within this rectangle, inclusive of its edges. + + /// + + ///# Examples + + /// + + ///```rust + + ///# use bevy_math::Rect; + + ///let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 + + ///assert!(r.contains(r.center())); + + ///assert!(r.contains(r.min)); + + ///assert!(r.contains(r.max)); + + ///``` + + #[lua( + + + + )] + fn contains ( + + + &self, + + + + + #[proxy] + + point : bevy::math::f32::Vec2, + + + + ) + + + -> bool + + ; +"#, + r#" + + ///Build a new rectangle formed of the union of this rectangle and another rectangle. + + /// + + ///The union is the smallest rectangle enclosing both rectangles. + + /// + + ///# Examples + + /// + + ///```rust + + ///# use bevy_math::{Rect, Vec2}; + + ///let r1 = Rect::new(0., 0., 5., 1.); // w=5 h=1 + + ///let r2 = Rect::new(1., -1., 3., 3.); // w=2 h=4 + + ///let r = r1.union(r2); + + ///assert!(r.min.abs_diff_eq(Vec2::new(0., -1.), 1e-5)); + + ///assert!(r.max.abs_diff_eq(Vec2::new(5., 3.), 1e-5)); + + ///``` + + #[lua( + + + + output(proxy), + + )] + fn union ( + + + &self, + + + + + #[proxy] + + other : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Build a new rectangle formed of the union of this rectangle and a point. + + /// + + ///The union is the smallest rectangle enclosing both the rectangle and the point. If the + + ///point is already inside the rectangle, this method returns a copy of the rectangle. + + /// + + ///# Examples + + /// + + ///```rust + + ///# use bevy_math::{Rect, Vec2}; + + ///let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 + + ///let u = r.union_point(Vec2::new(3., 6.)); + + ///assert!(u.min.abs_diff_eq(Vec2::ZERO, 1e-5)); + + ///assert!(u.max.abs_diff_eq(Vec2::new(5., 6.), 1e-5)); + + ///``` + + #[lua( + + + + output(proxy), + + )] + fn union_point ( + + + &self, + + + + + #[proxy] + + other : bevy::math::f32::Vec2, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Build a new rectangle formed of the intersection of this rectangle and another rectangle. + + /// + + ///The intersection is the largest rectangle enclosed in both rectangles. If the intersection + + ///is empty, this method returns an empty rectangle ([`Rect::is_empty()`] returns `true`), but + + ///the actual values of [`Rect::min`] and [`Rect::max`] are implementation-dependent. + + /// + + ///# Examples + + /// + + ///```rust + + ///# use bevy_math::{Rect, Vec2}; + + ///let r1 = Rect::new(0., 0., 5., 1.); // w=5 h=1 + + ///let r2 = Rect::new(1., -1., 3., 3.); // w=2 h=4 + + ///let r = r1.intersect(r2); + + ///assert!(r.min.abs_diff_eq(Vec2::new(1., 0.), 1e-5)); + + ///assert!(r.max.abs_diff_eq(Vec2::new(3., 1.), 1e-5)); + + ///``` + + #[lua( + + + + output(proxy), + + )] + fn intersect ( + + + &self, + + + + + #[proxy] + + other : Self, + + + + ) + + + -> Self + + ; +"#, + r#" + + ///Create a new rectangle with a constant inset. + + /// + + ///The inset is the extra border on all sides. A positive inset produces a larger rectangle, + + ///while a negative inset is allowed and produces a smaller rectangle. If the inset is negative + + ///and its absolute value is larger than the rectangle half-size, the created rectangle is empty. + + /// + + ///# Examples + + /// + + ///```rust + + ///# use bevy_math::{Rect, Vec2}; + + ///let r = Rect::new(0., 0., 5., 1.); // w=5 h=1 + + ///let r2 = r.inset(3.); // w=11 h=7 + + ///assert!(r2.min.abs_diff_eq(Vec2::splat(-3.), 1e-5)); + + ///assert!(r2.max.abs_diff_eq(Vec2::new(8., 4.), 1e-5)); + + /// + + ///let r = Rect::new(0., -1., 6., 7.); // w=6 h=8 + + ///let r2 = r.inset(-2.); // w=11 h=7 + + ///assert!(r2.min.abs_diff_eq(Vec2::new(2., 1.), 1e-5)); + + ///assert!(r2.max.abs_diff_eq(Vec2::new(4., 5.), 1e-5)); + + ///``` + + #[lua( + + + + output(proxy), + + )] + fn inset ( + + + &self, + + + + + inset : f32, + + + + ) + + + -> Self + + ; +"#, + ] +)] +pub struct Rect; #[cfg(feature = "lua")] -crate::impl_tealr_generic!(pub(crate) struct T); +crate::impl_tealr_generic!(pub (crate) struct T); #[cfg(feature = "lua")] #[derive(Default)] pub(crate) struct BevyAPIGlobals; @@ -10204,210 +87749,6 @@ impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for BevyAPIGlobals { self, instances: &mut T, ) -> bevy_mod_scripting_lua::tealr::mlu::mlua::Result<()> { - instances.add_instance( - "Overflow", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "UiImage", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "Name", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "Text", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "TextSection", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "Stopwatch", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "Timer", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "Entity", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "Transform", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "TextureAtlasSprite", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "RenderLayers", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "Color", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "Aabb", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "Frustum", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "CameraRenderGraph", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "HandleId", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "Vec2", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "Vec3", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "Vec3A", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "Vec4", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "BVec2", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "BVec3", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "BVec4", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "BVec3A", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "BVec4A", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "DVec2", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "DVec3", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "DVec4", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "IVec2", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "IVec3", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "IVec4", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "UVec2", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "UVec3", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "UVec4", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "Mat3", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "Mat2", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "Mat3A", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "Mat4", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "DMat2", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "DMat3", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "DMat4", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "Affine2", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "Affine3A", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "DAffine2", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "DAffine3", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "Quat", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "DQuat", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "Rect", - bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::::new, - )?; - instances.add_instance( - "world", - crate::lua::util::DummyTypeName::::new, - )?; - instances.add_instance( - "script", - crate::lua::util::DummyTypeName::::new, - )?; - instances.add_instance( - "entity", - crate::lua::util::DummyTypeName::::new, - )?; Ok(()) } } @@ -10426,173 +87767,7 @@ impl APIProvider for LuaBevyAPIProvider { .map_err(|e| ScriptError::Other(e.to_string())) } fn get_doc_fragment(&self) -> Option { - Some(LuaDocFragment::new("BevyAPI", |tw| { - tw - .document_global_instance::().expect("Something went wrong documenting globals") - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::>() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::>() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::>() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::>() - .process_type::() - .process_type::() - .process_type::>() - .process_type::() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::>() - .process_type::() - .process_type::() - .process_type::>() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::() - .process_type::>() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::>() - .process_type::() - .process_type::() - .process_type::() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::() - .process_type::>() - .process_type::() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - .process_type::() - .process_type::>() - })) + Some(LuaDocFragment::new("BevyAPI", |tw| tw)) } fn setup_script( &mut self, @@ -10610,10 +87785,8 @@ impl APIProvider for LuaBevyAPIProvider { globals .set::<_, crate::lua::bevy::LuaScriptData>("script", script_data.into()) .map_err(ScriptError::new_other)?; - Ok(()) } - fn setup_script_runtime( &mut self, world_ptr: bevy_mod_scripting_core::world::WorldPointer, @@ -10626,130 +87799,5 @@ impl APIProvider for LuaBevyAPIProvider { .set("world", crate::lua::bevy::LuaWorld::new(world_ptr)) .map_err(ScriptError::new_other) } - fn register_with_app(&self, app: &mut App) { - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::(); - app.register_foreign_lua_type::